Basically, I would like to change the significant figure of a cell based on the number of significant figure of another cell.
I got a formula that works in worksheet cell, the source of magic formula: https://stackoverflow.com/a/41891803/9111492
And now, I would like to move that formula to vbe so that the formula is insert to a cell when the button is pressed. But I am facing an error.
Here's the code that I had edited and got an
error 1004
Dim NRC As Range
Range(NRC.Offset(-1, 35), NRC.Offset(-1, 38)).Formula = _
"=TEXT(IF(" & NRC.Offset(-1, 39).Address & "<0,""-"","""")&LEFT(TEXT(ABS(" & NRC.Offset(-1, 39).Address & "),""0.""&REPT(""0""," & NRC.Offset(-1, 41).Address & "-1)&""E+00"")," & NRC.Offset(-1, 41).Address & "+1)*10^FLOOR(LOG10(TEXT(ABS(" & NRC.Offset(-1, 39).Address & "),""0.""&REPT(""0""," & NRC.Offset(-1, 41).Address & "-1)&""E+00"")),1),(""""&(IF(OR(AND(FLOOR(LOG10(TEXT(ABS(" & NRC.Offset(-1, 39).Address & "),""0.""&REPT(""0""," & NRC.Offset(-1, 41).Address & "-1)&""E+00"")),1)+1=" & NRC.Offset(-1, 41).Address & ",RIGHT(LEFT(TEXT(ABS(" & NRC.Offset(-1, 39).Address & "),""0.""&REPT(""0""," & NRC.Offset(-1, 41).Address & "-1)&""E+00"")," & NRC.Offset(-1, 41).Address & "+1)*10^FLOOR(LOG10(TEXT(ABS(" & NRC.Offset(-1, 39).Address & "),""" & _
"T(""0""," & NRC.Offset(-1, 41).Address & "-1)&""E+00"")),1),1)=""0""),LOG10(TEXT(ABS(" & NRC.Offset(-1, 39).Address & "),""0.""&REPT(""0""," & NRC.Offset(-1, 41).Address & "-1)&""E+00""))<=" & NRC.Offset(-1, 41).Address & "-1),""0."",""#"")&REPT(""0"",IF(" & NRC.Offset(-1, 41).Address & "-1-(FLOOR(LOG10(TEXT(ABS(" & NRC.Offset(-1, 39).Address & "),""0.""&REPT(""0""," & NRC.Offset(-1, 41).Address & "-1)&""E+00"")),1))>0," & NRC.Offset(-1, 41).Address & "-1-(FLOOR(LOG10(TEXT(ABS(" & NRC.Offset(-1, 39).Address & "),""0.""&REPT(""0""," & NRC.Offset(-1, 41).Address & "-1)&""E+00"")),1)),0)))))"
NRC is the name for a range
NRC.Offset(-1, 39) is the cell that contain the number that I would like to change the significant number
NRC.Offset(-1, 41) Is the cell that contain the number of significant figure
Any help is appreciated!