Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 385
Default So easy you will probably laugh

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default So easy you will probably laugh

"Jennifer" wrote in message
...
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


Hi Jennifer,

Try:

With Worksheets("YourDatabaseSheetName")
.Range("m2", .Range("l2").End(xlDown)).Offset(1, 1).FillDown
End With

Note the prepending dot before each instance of Range.

If you do not qualify the range addresses, the reference will always be to
the currently active sheet.

---
Regards,
Norman




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default So easy you will probably laugh

Sheets("database").Select

--


Gary


"Jennifer" wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default So easy you will probably laugh

Prequalify the range with a worksheet reference

Worksheets("Database").Range.......... etc.

--
Cheers
Nigel



"Gary Keramidas" wrote in message
...
Sheets("database").Select

--


Gary


"Jennifer" wrote in message
...
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





  #5   Report Post  
Posted to microsoft.public.excel.programming
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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 385
Default So easy you will probably laugh

Sorry, i didn't read your reply's until today. Sometimes I need a few days to
detox. K'Dales thank you so much for the extended answer, I to am a teacher
at heart and sometimes as a vocation so I really enjoy it when someone takes
the time to really explain the answer. Thank you so much. I will work hard to
understand your reply.
Regards,
Jennifer
--
Though daily learning, I LOVE EXCEL!
Jennifer


"K Dales" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Should be easy but....... Steve Excel Discussion (Misc queries) 5 February 5th 09 03:32 PM
pls help, is there an easy way to [email protected] Excel Worksheet Functions 12 May 3rd 07 07:04 PM
This should be easy... Jerry Excel Worksheet Functions 9 December 6th 05 04:17 PM
This should be easy Kypreo Excel Worksheet Functions 5 November 22nd 05 05:28 AM
new user with easy question? not easy for me speakeztruth New Users to Excel 5 June 3rd 05 09:40 PM


All times are GMT +1. The time now is 12:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"