excel vba syntax

  • 14 years ago

    I have the following code.......

    Selection.AutoFill Destination:=Range("E1:E795"), Type:=xlFillDefault

    I would like to substitute a variable named "count",  for the 795. When I try to, I keep getting an error.  Anybody?

    thx---kwwm

  • 14 years ago
    You don't say what error you are getting. I had a similar problem when trying to use a variable in a Range description.
    The solution in my case was to use (using your example):

    Range("E1:E" & count)

    You need to use the "&" operator, NOT "+", as the "&" does type conversion without adding any extraneous stuff.






  • 14 years ago

    I did it and it worked---thanks a lot!---kwwm

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint Exupéry