Help needed with Changing the Value of a Formula in a For Statement..

This is probably a very simple issue, but I have been working on this VBA Script for too long to see it, so please someone HELP!!!

I have a Macro as follows:

For Each c In Worksheets("Sheet2").Range("C4:AW4").Cells
c.Formula = "=IF(Sheet1!F31="""","""",Sheet1!F31)"
End Sub

This macro copies the "c.Formula" across Sheet2 From cell F4 to column AW4. This is all working fine. What I have a problem with is changing the "Sheet1!F31" value as I move across, so for example, what I want is:

Cell C4: .Formula = "=IF(Sheet1!G31="""","""",Sheet1!G31)"
Cell C5: .Formula = "=IF(Sheet1!H31="""","""",Sheet1!H31)"
Cell C6: .Formula = "=IF(Sheet1!I31="""","""",Sheet1!I31)"

Please Help!

(p.s. Don't know why there is a space between !I3 1 as there isn't in my code and there isn't in my typing")
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!