View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
K Dales[_2_] K Dales[_2_] is offline
external usenet poster
 
Posts: 1,163
Default So easy you will probably laugh

No laughing here - we all had to learn. I can see from all your posts that
you are working hard on learning Excel/VBA, so keep it up!

And as a general answer in addition to the other posts: when working with
multiple worksheets, workbooks, etc. I try to always reference everything to
the "highest level" object necessary. That is, if working strictly within
one workbook but with multiple sheets, I will always use
Worksheets("SheetName").Range(Address)...; if I am working simultaneously
with many workbooks I will specify
Workbooks("BookName").Worksheets("SheetName").Rang e(Address)... and so on.
Better yet, if I am going to use these repeatedly, is to use the With... End
With structure or else assign the worksheet to a variable:
Dim MySheet as Worksheet
Set MySheet=Workbooks("BookName").Worksheets("SheetNam e")
It helps avoid confusion both as I oringially code it and - more importantly
- when sometime down the road I (or someone else) needs to debug or modify
it!

Long answer to a short question - but I am a teacher at heart (and, at
times, by vocation)!

"Jennifer" wrote:

Hello,
I want this to run this when i hit a button <add in my form. It works great
if the correct worksheet is open, but I don't run the form in this sheet so
again how do I tell it to look on the database worksheet?
'checks how many rows have data in l and copies the formula down in m
Range("m2", Range("l2").End(xlDown)).Offset(1, 1).FillDown

Thanks guys--
Though daily learning, I LOVE EXCEL!
Jennifer