Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 9th, 2009, 11:25 PM
Authorized User
 
Join Date: Feb 2009
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
Default VBA Copy Help

Hi, I'm newly to here's, also I very new to work in VBA now I have problems as I not sure VB can work or not wanna some one help,

I have progamme want to copy form sheet1("H1") to paste at sheet2( column A, count the last row and down to if column "B last value,


sample:

if sheet2 COL A last row is "A18, and the COL "B" last row are B50, the copying is form sheet1 HI, to sheet2 A19 to A50,

can the criteria base on COL B and start copy count by last row at COL A??

can u help me the code?

pleased
 
Old February 10th, 2009, 01:58 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Here is a way to achieve that

Code:
Sub Copy_KS()
Dim iALast As Long
Dim iBLast As Long

iALast = Worksheets("Sheet2").Range("A65336").End(xlUp).Row
iBLast = Worksheets("Sheet2").Range("B65336").End(xlUp).Row
Worksheets("Sheet1").Range("H1").Copy Destination:=Worksheets("Sheet2").Range("A" & iALast + 1 & ":A" & iBLast)
End Sub
Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old February 10th, 2009, 02:17 AM
Authorized User
 
Join Date: Feb 2009
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Dear Shasur


Excellent the code tha's what me looking for... you're be Wizard


Thanks
 
Old February 10th, 2009, 10:13 PM
Authorized User
 
Join Date: Feb 2009
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Dear Shasur


Sorry the troublems .... may i have you help again the code if I want just to paste the values only.



your help I have hightly appreciate
 
Old February 10th, 2009, 10:41 PM
Authorized User
 
Join Date: Nov 2007
Posts: 48
Thanks: 0
Thanked 4 Times in 4 Posts
Default

ks1102,

Try:

Code:
 
Option Explicit
Sub Copy_KS()
    Dim iALast As Long
    Dim iBLast As Long
    iALast = Worksheets("Sheet2").Range("A65336").End(xlUp).Row
    iBLast = Worksheets("Sheet2").Range("B65336").End(xlUp).Row
    Worksheets("Sheet1").Range("H1").Copy Destination:=Worksheets("Sheet2").Range("A" & iALast + 1 & ":A" & iBLast)
    With Worksheets("Sheet2").Range("A" & iALast + 1 & ":A" & iBLast)
        .Value = .Value
    End With
End Sub

Have a great day,
Stan
__________________
stanleydgromjr

Windows 8.1, Excel 2007.
 
Old February 10th, 2009, 11:08 PM
Authorized User
 
Join Date: Feb 2009
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Dear all

Thanks very much





Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel VBA copy & paste wensmail Excel VBA 1 September 17th, 2007 11:13 PM
copy one record to another table using VBA kitaeshi Access VBA 1 June 11th, 2007 06:50 AM
Excel VBA Problems with copy and paste bripers Excel VBA 6 September 1st, 2006 05:14 AM
Copy data from webpage to excel using vba kg8299 Excel VBA 0 April 5th, 2006 03:51 AM
MS Access, VBA code to copy recordset Ivan Classic ASP Databases 1 November 1st, 2003 05:52 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.