I'm new to VBA and writing macros, and I'm not familiar with the proper syntax for generating my own code. I would really appreciate some help with this, it would make life a lot easier if I could write a macro to do what I'm currently doing with formulas.
Lets say I'm using the following formula, which I have pasted all down column D. Based on whatever row we've pasted this into, were going to see whats in column B, then check whats in column C, then check to see if I2 contains anything (this is a box I use to switch between metric and standard), and based on all this criteria, we output something like:
whateverswritteninB3 (0.000)
=B3&IF(ISBLANK($C3),"",IF(ISBLANK$I$2)," ("&TEXT($C3,"0.000")&")"," ("TEXT(($C3/25.4),"0.0000")&")"))
I'd like to do this in VBA, and while I dont know the proper syntax, the way I'm thinking about it in my head is:
dim InDes as ??, InVal as ??
InDes = target.offset(0,-2) 'this cell could contain text or a formula. I want to copy whatever the cell is actually showing.
InVal = if target.offset(0,-1) = "" then InVal = ""
elseif
cell I2 is empty then
InVal = value.target.offset(0,-1)
force format of 0.000
elseif
cell I2 is not empty then
InVal = value.target.offset(0,-1)/25.4
force fromat of 0.0000
If (Not Intersect(Target, Range("D:D")) Is Nothing) Then
If (Not IsEmpty(Target)) Then
if InVal = "" then
target = InDes
else
target = InDes & " (" & InVal & ")"
Bookmarks