A
Andy
Hello,
I've been trying learn, very slowly, how to do some things with macros. The
book I have, as well as many of the posts I've read over, say to not Select
things, but to just act on the range or cells directly. I'm posting part of
a macro I've written with a couple of questions in the text lines.
Sheets("Prior_Rev3").Range("A:E").Copy
Sheets("Rev_Final").Range("A1").PasteSpecial xlPasteValues
Application.CutCopyMode = False
Sheets("Criteria").Select
'Range("C7:C7").Select
'M = ActiveCell.Offset(0, 0).Value
M = Range("C7").Value
Select Case M
Case "January"
Sheets("Prior_Rev3").Range("F:Q").Copy
Sheets("Rev_Final").Range("F1").PasteSpecial xlPasteValues
Application.CutCopyMode = False
Sheets("Current_Rev3").Select
' These next lines do not work - WHY ?
' Sheets("Current_Rev3").Range("A2:E2", Range("A2:E2").End(xlDown)).Copy
' Sheets("Current_Rev3").Range("A2:E2").End(xlDown)).Copy
' On the next line of code, why is the ranged listed twice ?
Range("A2:E2", Range("A2:E2").End(xlDown)).Copy
Sheets("Rev_Final").Range("A1").End(xlDown).Offset(1, 0). _
PasteSpecial xlPasteValues
Application.CutCopyMode = False
Sheets("Current_Rev3").Select
Range("F2", Range("F2").End(xlDown)).Copy
Sheets("Rev_Final").Range("F1").End(xlDown).Offset(1, 12). _
PasteSpecial xlPasteValues
Application.CutCopyMode = False
My questions are in the text lines of the January case. Basically, why does
the first line of the case work without having to select the sheet first, but
the following line has to have the sheet selected and why don't the two lines
that I've marked, work?
Sheets("Current_Rev3").Select
Range("A2:E2", Range("A2:E2").End(xlDown)).Copy
Sheets("Rev_Final").Range("A1").End(xlDown).Offset(1, 0). _
PasteSpecial xlPasteValues
Also, in some posts I've seen Destination:=
When is this used, as opposed to just tacking the sheet name on the front of
the line, as in
Sheets("Rev_Final").Range("F1").PasteSpecial xlPasteValues
I hope this is clear, as most of what I'm able to write is completely robbed
and reworked from the posts in this forum.
Thanks in advance,
Andy
I've been trying learn, very slowly, how to do some things with macros. The
book I have, as well as many of the posts I've read over, say to not Select
things, but to just act on the range or cells directly. I'm posting part of
a macro I've written with a couple of questions in the text lines.
Sheets("Prior_Rev3").Range("A:E").Copy
Sheets("Rev_Final").Range("A1").PasteSpecial xlPasteValues
Application.CutCopyMode = False
Sheets("Criteria").Select
'Range("C7:C7").Select
'M = ActiveCell.Offset(0, 0).Value
M = Range("C7").Value
Select Case M
Case "January"
Sheets("Prior_Rev3").Range("F:Q").Copy
Sheets("Rev_Final").Range("F1").PasteSpecial xlPasteValues
Application.CutCopyMode = False
Sheets("Current_Rev3").Select
' These next lines do not work - WHY ?
' Sheets("Current_Rev3").Range("A2:E2", Range("A2:E2").End(xlDown)).Copy
' Sheets("Current_Rev3").Range("A2:E2").End(xlDown)).Copy
' On the next line of code, why is the ranged listed twice ?
Range("A2:E2", Range("A2:E2").End(xlDown)).Copy
Sheets("Rev_Final").Range("A1").End(xlDown).Offset(1, 0). _
PasteSpecial xlPasteValues
Application.CutCopyMode = False
Sheets("Current_Rev3").Select
Range("F2", Range("F2").End(xlDown)).Copy
Sheets("Rev_Final").Range("F1").End(xlDown).Offset(1, 12). _
PasteSpecial xlPasteValues
Application.CutCopyMode = False
My questions are in the text lines of the January case. Basically, why does
the first line of the case work without having to select the sheet first, but
the following line has to have the sheet selected and why don't the two lines
that I've marked, work?
Sheets("Current_Rev3").Select
Range("A2:E2", Range("A2:E2").End(xlDown)).Copy
Sheets("Rev_Final").Range("A1").End(xlDown).Offset(1, 0). _
PasteSpecial xlPasteValues
Also, in some posts I've seen Destination:=
When is this used, as opposed to just tacking the sheet name on the front of
the line, as in
Sheets("Rev_Final").Range("F1").PasteSpecial xlPasteValues
I hope this is clear, as most of what I'm able to write is completely robbed
and reworked from the posts in this forum.
Thanks in advance,
Andy