URGENT problem with Autofill in a macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I wrote a macro which uses Autofill and End(xlDown) to fill in twenty or so
blank cells in a column before hitting text below. When I perform the macro
on my computer it works fine; however, on my client's computer, executing the
macro replaces the ENTIRE column of text, overwriting all data below rather
than just filling in blank cells until it hits text/data.

Specifically, the formula I'm using, (which should copy the contents of
E12:G12 down through a series of blank cells until it hits text) is:

Range("E12:G12").AutoFill Destination:=Range("E12", Range("G12").End(xlDown)
(0))

Any ideas what might cause this and how to fix?????

MANY, MANY, MANY THANKS,

Marika :)
 
What happens if you eliminate that stray (0) at the end?

To debug, I would try identifying the cell found with End(xlDown), i.e.

Set Rng1 = Range("E12:G12")
Set Rng2 = Range("G12").End(xlDown)
Debug.Print Rng2.Address
 
This is a side question.This Debug.Print thing....where does it print?
I have tried before to use this and I can't find anything in any of my
open books. A simple thing I know but it's usually the simplest that
catch you out!
Donna
 
Hi Donna,

In the project explorer, make the debug toolbar visible and click the
immediate window icon (the one with an exclamation mark).
This is very handy to control exectution of your code, or to assign value to
variable which are not yet initialised.
To get info in the immediate window , use debug.print in your sub
(eg debug.print "Age variable value = " & myVarAge)
To ask value in debug mode, type directly in the immediate window : << ?
myVarAge>>enter.
The ? is like debug.print in sub. You can also assign value by typing :
<<myVarAge= 18>>

Regards
Jean-Yves
 
Back
Top