I have a very simple sub in excel vba:
Private Sub AlignText(r As Integer, c As Integer) 'A sub to align the data in the cell
.Cells(r, c).HorizontalAlignment = xlCenter
.Cells(r, c).VerticalAlignment = xlCenter
I just want to supply column and row numbers to align text. I have tried putting in the full path to the cells using full sheet references too, but that doesn't help.
When I try to use the sub:
for example, I get the error:
'Compile error: Expected: ='
I have written very very similar subs before, that aligned text as well as doing other things, and they have worked fine. This must be something simple, but I don't know what.
Thanks in advance for any help.