Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default Active sheet instead of a "sheet1" for Macro

I have this code in a macro:
If Sheets("Sheet1").[A1] = True Then
ActiveWindow.SmallScroll Down:=-9
Application.Goto Reference:="R17C3"
Range("C11:C17").Select
Range("C17").Activate
Selection.Copy

My questions is how do I make this macro work in any worksheet not
only only in sheet1, what do i have to change from "Sheet1" to make it
work.
thank you,

Pamela
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Active sheet instead of a "sheet1" for Macro

If Activesheet.range("a1").value = True Then



Pantera wrote:

I have this code in a macro:
If Sheets("Sheet1").[A1] = True Then
ActiveWindow.SmallScroll Down:=-9
Application.Goto Reference:="R17C3"
Range("C11:C17").Select
Range("C17").Activate
Selection.Copy

My questions is how do I make this macro work in any worksheet not
only only in sheet1, what do i have to change from "Sheet1" to make it
work.
thank you,

Pamela


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default Active sheet instead of a "sheet1" for Macro

Sub copyif1()
With ActiveSheet
If .Range("A1") = True Then
.Range("C11:C17").Copy .Range("d5")
End If
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Pantera" wrote in message
...
I have this code in a macro:
If Sheets("Sheet1").[A1] = True Then
ActiveWindow.SmallScroll Down:=-9
Application.Goto Reference:="R17C3"
Range("C11:C17").Select
Range("C17").Activate
Selection.Copy

My questions is how do I make this macro work in any worksheet not
only only in sheet1, what do i have to change from "Sheet1" to make it
work.
thank you,

Pamela


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,624
Default Active sheet instead of a "sheet1" for Macro

One way:

If ActiveSheet.Range("A1").Value = True Then
ActiveSheet.Range("C11:C7").Copy
End If

Or, equivalently:

With ActiveSheet
If .Range("A1").Value = True Then .Range("C11:C17").Copy
End With


In article
,
Pantera wrote:

I have this code in a macro:
If Sheets("Sheet1").[A1] = True Then
ActiveWindow.SmallScroll Down:=-9
Application.Goto Reference:="R17C3"
Range("C11:C17").Select
Range("C17").Activate
Selection.Copy

My questions is how do I make this macro work in any worksheet not
only only in sheet1, what do i have to change from "Sheet1" to make it
work.
thank you,

Pamela

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default Active sheet instead of a "sheet1" for Macro

On Dec 31, 10:10*am, JE McGimpsey wrote:
One way:

* *If ActiveSheet.Range("A1").Value = True Then
* * * * *ActiveSheet.Range("C11:C7").Copy
* *End If

Or, equivalently:

* *With ActiveSheet
* * * If .Range("A1").Value = True Then .Range("C11:C17").Copy
* *End With

In article
,



*Pantera wrote:
I have this code in a macro:
If Sheets("Sheet1").[A1] = True Then
* * ActiveWindow.SmallScroll Down:=-9
* * Application.Goto Reference:="R17C3"
* * Range("C11:C17").Select
* * Range("C17").Activate
* * Selection.Copy


My questions is how do I make this macro work in any worksheet not
only only in sheet1, what do i have to change from "Sheet1" to make it
work.
thank you,


Pamela- Hide quoted text -


- Show quoted text -


Thank you!!! works like a charm.
Pamela


  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,346
Default Active sheet instead of a "sheet1" for Macro

Hi,

A few general point alluded to in the earlier responses:

1. You don't need to select a range to work with it.
2. The recorder is verbose, although it is a great starting point you can
often eliminate much of what it generates.

So you macro becomes

If [A1] = True Then
[C11:C17].Copy [X1]
.... more code
End if
End With

This macro assume that you want to copy the data to the range starting in
cell X1. Also, it assumes that you are in the same sheet as the cell A1. In
which case there is no need to reference any sheet since this code assumes
the active sheet.

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Pantera" wrote:

I have this code in a macro:
If Sheets("Sheet1").[A1] = True Then
ActiveWindow.SmallScroll Down:=-9
Application.Goto Reference:="R17C3"
Range("C11:C17").Select
Range("C17").Activate
Selection.Copy

My questions is how do I make this macro work in any worksheet not
only only in sheet1, what do i have to change from "Sheet1" to make it
work.
thank you,

Pamela

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default Active sheet instead of a "sheet1" for Macro

On Dec 31, 10:05*am, Dave Peterson wrote:
If Activesheet.range("a1").value = True Then





Pantera wrote:

I have this code in a macro:
If Sheets("Sheet1").[A1] = True Then
* * ActiveWindow.SmallScroll Down:=-9
* * Application.Goto Reference:="R17C3"
* * Range("C11:C17").Select
* * Range("C17").Activate
* * Selection.Copy


My questions is how do I make this macro work in any worksheet not
only only in sheet1, what do i have to change from "Sheet1" to make it
work.
thank you,


Pamela


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Thanks!!!
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 896
Default Active sheet instead of a "sheet1" for Macro

or briefly:

If ActiveSheet.Range("A1").Value Then


On 31 Gru, 18:57, Pantera wrote:
I have this code in a macro:
If Sheets("Sheet1").[A1] = True Then
* * ActiveWindow.SmallScroll Down:=-9
* * Application.Goto Reference:="R17C3"
* * Range("C11:C17").Select
* * Range("C17").Activate
* * Selection.Copy

My questions is how do I make this macro work in any worksheet not
only only in sheet1, what do i have to change from "Sheet1" to make it
work.
thank you,

Pamela


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
how do copy "sheet1!A1+1 in sheet2 to sheet 3 and get "sheet2!A1+ Dany Excel Discussion (Misc queries) 5 April 16th 07 03:27 AM
Macro to email with "active row" info Ron de Bruin Excel Discussion (Misc queries) 13 October 25th 06 07:31 PM
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" Dennis Excel Discussion (Misc queries) 0 July 17th 06 02:38 PM
How do I color code the "SHEET1" Tab in Excel? kmtg Excel Worksheet Functions 3 June 14th 06 04:13 PM
Macro to run on the "Active Sheet" David P. Excel Discussion (Misc queries) 8 April 11th 06 07:42 PM


All times are GMT +1. The time now is 07:22 AM.

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"