ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Active sheet instead of a "sheet1" for Macro (https://www.excelbanter.com/excel-worksheet-functions/215055-active-sheet-instead-sheet1-macro.html)

Pantera

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

Dave Peterson

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

Don Guillett

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



JE McGimpsey

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


Pantera

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

Shane Devenshire[_2_]

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


Pantera

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!!!

Jarek Kujawa[_2_]

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




All times are GMT +1. The time now is 03:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com