Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add data range to a specific tab based on "Sheet Name"
I currently have a macro (script below) which copy&pastes a data range(from
"CashEntry" sheet, cells $C$2:$P$3) to the bottom of a list (on another sheet ""CashTransferRecord") . How can I do this with multiple sheets instead of just one sheet named "CashTransferRecord"? Basically, I want macro to look at cell X2 on "CashEntry" tab to identify the tab's name where i want the data range to be added to. I want to add data records to a multiple selection of tabs solely based on the name in cell X2. Can you help? Your help is very appreciated! _________________________________ Sub CopyPasteOntoDatabase() Sheets("CashTransferRecord").Select If Cells(2, 3).Value = Empty Then Worksheets("CashEntry").Range("$C$2:$P$3").Copy Worksheets("CashTransferRecord").Range("C2").Paste Special (xlPasteValues) Else Worksheets("CashEntry").Range("$C$2:$P$3").Copy Worksheets("CashTransferRecord").Range("C65000").E nd(xlUp).Offset(1, 0).Cells.PasteSpecial (xlPasteValues) End If End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add data range to a specific tab based on "Sheet Name"
On 8 Jan., 04:24, Brice wrote:
I currently have a macro (script below) *which copy&pastes a data range(from "CashEntry" sheet, cells $C$2:$P$3) to the bottom of a list (on another sheet ""CashTransferRecord") . How can I do this with multiple sheets instead of just one sheet named "CashTransferRecord"? Basically, I want macro to look at cell X2 on "CashEntry" tab to identify the tab's name where i want the data range to be added to. I want to add data records to a multiple selection of tabs solely based on the name in cell X2. Can you help? Your help is very appreciated! _________________________________ Sub CopyPasteOntoDatabase() Sheets("CashTransferRecord").Select If Cells(2, 3).Value = Empty Then Worksheets("CashEntry").Range("$C$2:$P$3").Copy Worksheets("CashTransferRecord").Range("C2").Paste Special (xlPasteValues) Else Worksheets("CashEntry").Range("$C$2:$P$3").Copy Worksheets("CashTransferRecord").Range("C65000").E nd(xlUp).Offset(1, 0).Cells.PasteSpecial (xlPasteValues) End If End Sub Hi If entry in X2 is equal to a sheetname then you can use something like this. shName=range("X2").value sheets(shName).range("C2").pastespecial(xlPasteVal ues) Note that it will be case sensitive. //Per |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add data range to a specific tab based on "Sheet Name"
Where exactly do I put this? Can you write the full script (I'm a rookie at
VBA)? Thanks! "Per Jessen" wrote: On 8 Jan., 04:24, Brice wrote: I currently have a macro (script below) which copy&pastes a data range(from "CashEntry" sheet, cells $C$2:$P$3) to the bottom of a list (on another sheet ""CashTransferRecord") . How can I do this with multiple sheets instead of just one sheet named "CashTransferRecord"? Basically, I want macro to look at cell X2 on "CashEntry" tab to identify the tab's name where i want the data range to be added to. I want to add data records to a multiple selection of tabs solely based on the name in cell X2. Can you help? Your help is very appreciated! _________________________________ Sub CopyPasteOntoDatabase() Sheets("CashTransferRecord").Select If Cells(2, 3).Value = Empty Then Worksheets("CashEntry").Range("$C$2:$P$3").Copy Worksheets("CashTransferRecord").Range("C2").Paste Special (xlPasteValues) Else Worksheets("CashEntry").Range("$C$2:$P$3").Copy Worksheets("CashTransferRecord").Range("C65000").E nd(xlUp).Offset(1, 0).Cells.PasteSpecial (xlPasteValues) End If End Sub Hi If entry in X2 is equal to a sheetname then you can use something like this. shName=range("X2").value sheets(shName).range("C2").pastespecial(xlPasteVal ues) Note that it will be case sensitive. //Per |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Add data range to a specific tab based on "Sheet Name"
Hello, can someone help with the below request. I need expert help. Thanks!
"Brice" wrote: Where exactly do I put this? Can you write the full script (I'm a rookie at VBA)? Thanks! "Per Jessen" wrote: On 8 Jan., 04:24, Brice wrote: I currently have a macro (script below) which copy&pastes a data range(from "CashEntry" sheet, cells $C$2:$P$3) to the bottom of a list (on another sheet ""CashTransferRecord") . How can I do this with multiple sheets instead of just one sheet named "CashTransferRecord"? Basically, I want macro to look at cell X2 on "CashEntry" tab to identify the tab's name where i want the data range to be added to. I want to add data records to a multiple selection of tabs solely based on the name in cell X2. Can you help? Your help is very appreciated! _________________________________ Sub CopyPasteOntoDatabase() Sheets("CashTransferRecord").Select If Cells(2, 3).Value = Empty Then Worksheets("CashEntry").Range("$C$2:$P$3").Copy Worksheets("CashTransferRecord").Range("C2").Paste Special (xlPasteValues) Else Worksheets("CashEntry").Range("$C$2:$P$3").Copy Worksheets("CashTransferRecord").Range("C65000").E nd(xlUp).Offset(1, 0).Cells.PasteSpecial (xlPasteValues) End If End Sub Hi If entry in X2 is equal to a sheetname then you can use something like this. shName=range("X2").value sheets(shName).range("C2").pastespecial(xlPasteVal ues) Note that it will be case sensitive. //Per |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Calcuting sum of specific word "P" within specific cell range (A5: | Excel Worksheet Functions | |||
If specific # of certain characters in a range, "OK", if not "Aler | Excel Worksheet Functions | |||
Validation ?:Accepting both Numbers AND specific letters("N","n"," | Excel Discussion (Misc queries) | |||
find "Cancellation" in column "A" and copy all data from Columns B-F onto another Sheet | Excel Programming | |||
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" | Excel Discussion (Misc queries) |