Kristylee0228
New Member
- Joined
- Sep 8, 2011
- Messages
- 30
Hi All -
I am looking to find how to use the Named Range to Copy and Paste from one document to another using VBA Code.
My macro currently uses a range to find the last blank cell in a row, but I can't figure out how to use that code in a different column.
The Macro opens "MyFile" and copies "D2". Then opens "RPCCalls_Count" and pastes into "B2". The ActiveSheet.Range("aRPCLastCell") finds the next blank row in Column B.
I would like another named range to jump over to Column C.
What the entire Macro is to do is copy Cell References from "MyFile" D2, D3, D4, D5 and F2, F3, F4, F5 and H2:H4 and Paste them into a new File named "RPCCalls_Count", Row 2.
Cells B through J. Column A is written text as the name of the Tab, "RPC Call 1", etc...
"MyFile" has 5 tabs named "RPC Call 1", "RPC Call 2" etc.. through "Call 5".
There's a loop to run through all the files within "MyFolder".
Any help to make this code easier would be greatly appreciated. As I am somewhat knowledgeable in VBA Code, but not much.
Here's the example code I have:
Workbooks.Open Filename:=MyFolder & "\" & MyFile, UpdateLinks:=False
Sheets("RPC Call 1").Select
Range("D2").Select
Selection.Copy
Workbooks.Open Filename:="\\ncbanalytics\Automation\Kristy\RPCCalls_Count.xlsx"
Sheets("CallCount").Select
Range("B2").Select
ActiveSheet.Range("aRPCLastCell").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A6").Select
Application.CutCopyMode = False
Workbooks(MyFile).Close SaveChanges:=False
MyFile = Dir
Loop
Application.ScreenUpdating = True
End Sub
Thank You -
Kristy
I am looking to find how to use the Named Range to Copy and Paste from one document to another using VBA Code.
My macro currently uses a range to find the last blank cell in a row, but I can't figure out how to use that code in a different column.
The Macro opens "MyFile" and copies "D2". Then opens "RPCCalls_Count" and pastes into "B2". The ActiveSheet.Range("aRPCLastCell") finds the next blank row in Column B.
I would like another named range to jump over to Column C.
What the entire Macro is to do is copy Cell References from "MyFile" D2, D3, D4, D5 and F2, F3, F4, F5 and H2:H4 and Paste them into a new File named "RPCCalls_Count", Row 2.
Cells B through J. Column A is written text as the name of the Tab, "RPC Call 1", etc...
"MyFile" has 5 tabs named "RPC Call 1", "RPC Call 2" etc.. through "Call 5".
There's a loop to run through all the files within "MyFolder".
Any help to make this code easier would be greatly appreciated. As I am somewhat knowledgeable in VBA Code, but not much.
Here's the example code I have:
Workbooks.Open Filename:=MyFolder & "\" & MyFile, UpdateLinks:=False
Sheets("RPC Call 1").Select
Range("D2").Select
Selection.Copy
Workbooks.Open Filename:="\\ncbanalytics\Automation\Kristy\RPCCalls_Count.xlsx"
Sheets("CallCount").Select
Range("B2").Select
ActiveSheet.Range("aRPCLastCell").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A6").Select
Application.CutCopyMode = False
Workbooks(MyFile).Close SaveChanges:=False
MyFile = Dir
Loop
Application.ScreenUpdating = True
End Sub
Thank You -
Kristy