I have a range of cells (E7:J50) that I need to put a leading apostrophy to any of the cells that are not empty. After my macro runs, I also need to remove the leading apostrophy from non empty cells (E7:J50)
Dim c As Range
For Each c In Range("E71:J50")
If c.Value <> "" Then
c.Value = "'" & c.Value
End If
Next
Hi
This will put an apostrophy to all cells that're not empty;
VBA Code:Dim c As Range For Each c In Range("E71:J50") If c.Value <> "" Then c.Value = "'" & c.Value End If Next
Just so I'm clear on the second point, the above code won't input data into any blank cells. Do you still need to remove the apostrophy for these other cells? If so, does the cell only have an apostrophy in it or is there some other contents too?