PC Review


Reply
Thread Tools Rate Thread

Add data range to a specific tab based on "Sheet Name"

 
 
Brice
Guest
Posts: n/a
 
      8th Jan 2008
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").PasteSpecial
(xlPasteValues)
Else
Worksheets("CashEntry").Range("$C$2:$P$3").Copy
Worksheets("CashTransferRecord").Range("C65000").End(xlUp).Offset(1,
0).Cells.PasteSpecial (xlPasteValues)
End If

End Sub

 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      8th Jan 2008
On 8 Jan., 04:24, Brice <Br...@discussions.microsoft.com> 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").PasteSpecial
> (xlPasteValues)
> Else
> Worksheets("CashEntry").Range("$C$2:$P$3").Copy
> Worksheets("CashTransferRecord").Range("C65000").End(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(xlPasteValues)

Note that it will be case sensitive.

//Per
 
Reply With Quote
 
Brice
Guest
Posts: n/a
 
      8th Jan 2008
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 <Br...@discussions.microsoft.com> 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").PasteSpecial
> > (xlPasteValues)
> > Else
> > Worksheets("CashEntry").Range("$C$2:$P$3").Copy
> > Worksheets("CashTransferRecord").Range("C65000").End(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(xlPasteValues)
>
> Note that it will be case sensitive.
>
> //Per
>

 
Reply With Quote
 
Brice
Guest
Posts: n/a
 
      10th Jan 2008
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 <Br...@discussions.microsoft.com> 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").PasteSpecial
> > > (xlPasteValues)
> > > Else
> > > Worksheets("CashEntry").Range("$C$2:$P$3").Copy
> > > Worksheets("CashTransferRecord").Range("C65000").End(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(xlPasteValues)
> >
> > Note that it will be case sensitive.
> >
> > //Per
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calcuting sum of specific word "P" within specific cell range (A5: billy liddel Microsoft Excel Worksheet Functions 3 26th Sep 2009 12:17 PM
Subform - display range based on "FROM" "TO" comboboxes in main fo NJBrit Microsoft Access Form Coding 3 4th Sep 2009 03:35 PM
If specific # of certain characters in a range, "OK", if not "Aler Steve Microsoft Excel Worksheet Functions 4 10th Jun 2009 07:05 PM
find "Cancellation" in column "A" and copy all data from Columns B-F onto another Sheet bjohnson Microsoft Excel Programming 1 20th Sep 2007 04:02 PM
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" Dennis Microsoft Excel Misc 0 17th Jul 2006 02:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:33 PM.