Home Simple vba sub giving error Compile error: Expected: =
Reply: 0

Simple vba sub giving error Compile error: Expected: =

user912
1#
user912 Published in April 24, 2018, 8:26 am

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
With ActiveSheet
    .Cells(r, c).HorizontalAlignment = xlCenter
    .Cells(r, c).VerticalAlignment = xlCenter
End Sub

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:

AlignText(NextRow, 16)

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.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.323833 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO