-
January 31st, 2007, 09:53 AM
#1
Copy and Paste
Hello,
I am creating an invoicing entry in one sheet and keeping those entry to another sheet as a master record using excel. I am doing this a repetitive action everyday.
What I understand I can record the activities in macro and possible to modify the code to a more feasible and reliable however I am newbie in visual basic programming. What I am trying to get through, how to make a code pasting the invoicing entry after the last row in the master worksheet
-
January 31st, 2007, 10:29 AM
#2
Re: Copy and Paste
U can copy some range from one sheet and paster after the last used cell of a column like this
Code:
Sub Macro3()
'
' Macro3 Macro
'
'
'
Sheets("Sheet1").Select // Select ur Source Sheet
Range("A1").Select // Select First Cell of Column A
Range(Selection, Selection.End(xlDown)).Select // Select complete column till end
Selection.Copy // Copy Values
Sheets("Sheet2").Select // Select Sheet2 ( Destination Sheet)
Dim nCount As Integer
nCount = Sheets("Sheet2").UsedRange.CurrentRegion.Rows.Count // Get Last used Row on Sheet2
Cells(nCount + 1, 1).Select // Select Last cell of Column A
ActiveSheet.Paste // Paster Values
End Sub
A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.
NAUMAAN
-
January 31st, 2007, 11:16 AM
#3
Re: Copy and Paste
Syntax error on this portion.
nCount = Sheets("Sheet2").UsedRange.CurrentRegion.Rows.Count // Get Last used Row on Sheet2
-
January 31st, 2007, 11:43 AM
#4
Re: Copy and Paste
I have checked this code , no syntax error
I have modified comments in this code plz try this.
Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 1/31/2007 by AAA
'
Sheets("Sheet1").Select ' Select ur Source Sheet
Range("A1").Select ' Select First Cell of Column A
Range(Selection, Selection.End(xlDown)).Select ' Select complete column till end
Selection.Copy ' Copy Values
Sheets("Sheet2").Select ' Select Sheet2 ( Destination Sheet)
Dim nCount As Integer
nCount = Sheets("Sheet2").UsedRange.CurrentRegion.Rows.Count ' Get Last used Row on Sheet2
Cells(nCount + 1, 1).Select ' Select Last cell of Column A
ActiveSheet.Paste ' Paster Values
'
End Sub
A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.
NAUMAAN
-
January 31st, 2007, 12:20 PM
#5
Re: Copy and Paste
Great!!!! The code is working perfectly. Now I can sit back and relax.
Thank you so much.
John
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|