Since you wanted an example, here it is :) But please note that this is not an answer. It's just that the comments will not be able to hold all this data plus it will ruin the formatting as well. Having said that, it is almost as good as an answer as it covers almost every aspect of what you want...
My Assumptions:
- Data is in Sheet1
- Col S and Col T are identical
Logic to achieve what you want
- Get the last row of Col S. For example see this
- Loop though the cells in Col S and check the number for decimals
- Use
.Numberformat
for format the cells in Col T based on the number of decimals in respective cell in Col S
Few code snippets
Looping Through cells in Col S
For i = 1 To LastRow
If Sheets("Sheet1").Range("S" & i) .... Then
End If
Next i
Setting the number format of cell T in the above loop
'~~> n below is the number of decimal places that you want
Sheets("Sheet1").Range("T" & i).NumberFormat = "0." & String(n, "0")
Incorporate all these and then try to come up with a code. Let use know where you are stuck and we will take it from there.