Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Code works fine....
Just want to ammend code to paste on next available row on "Data" sheet. ....starting in column A. Sub ABC() Dim cell As Range, c As Range Dim i As Range, rw As Long Dim sh As Worksheet With Worksheets("List") Set c = .Range(.Cells(6, "B"), .Cells(6, "B").End(xlDown)) Set i = .Range(.Cells(6, "I"), .Cells(6, "I").End(xlDown)) End With rw = 2 Set sh = Worksheets("Data") For Each cell In c If Application.CountIf(i, cell) 0 Then Range(cell, Cells(cell.Row, "G")).Copy sh.Cells(rw, 1) rw = rw + 1 End If Next End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Mar 10, 1:33*pm, "J.W. Aldridge"
wrote: Code works fine.... Just want to ammend code to paste on next available row on "Data" sheet. ...starting in column A. Sub ABC() Dim cell As Range, c As Range Dim i As Range, rw As Long Dim sh As Worksheet With Worksheets("List") Set c = .Range(.Cells(6, "B"), .Cells(6, "B").End(xlDown)) Set i = .Range(.Cells(6, "I"), .Cells(6, "I").End(xlDown)) End With rw = 2 Set sh = Worksheets("Data") For Each cell In c If Application.CountIf(i, cell) 0 Then * * Range(cell, Cells(cell.Row, "G")).Copy sh.Cells(rw, 1) * * rw = rw + 1 End If Next End Sub You already have one type of answer in your code (i.e. the .End). Also, try to keep your follow up questions in the original thread rather than reposting. Use the VBE help files to discover what .End and .CurrentRegion do and then experiment with the sample code. (You can search "End" and "CurrentRegion"). This should get you started with what you are looking to do. Matt Herbert |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Warning! You i and c will contain all the rows from 7 to 65536 if you data is
only 1 row. Sub ABC() Dim cell As Range, c As Range Dim i As Range, rw As Long Dim sh As Worksheet With Worksheets("List") Set c = .Range(.Cells(6, "B"), .Cells(6, "B").End(xlDown)) Set i = .Range(.Cells(6, "I"), .Cells(6, "I").End(xlDown)) End With Set sh = Worksheets("Data") LastRow = sh.cells(rows.count,rw).end(xlup).row NewRow = LastRow + 1 For Each cell In c If Application.CountIf(i, cell) 0 Then Range(cell, Cells(cell.Row, "G")).Copy sh.Cells(NewRow, 1) NewRow = NewRow + 1 End If Next End Sub "J.W. Aldridge" wrote: Code works fine.... Just want to ammend code to paste on next available row on "Data" sheet. ....starting in column A. Sub ABC() Dim cell As Range, c As Range Dim i As Range, rw As Long Dim sh As Worksheet With Worksheets("List") Set c = .Range(.Cells(6, "B"), .Cells(6, "B").End(xlDown)) Set i = .Range(.Cells(6, "I"), .Cells(6, "I").End(xlDown)) End With rw = 2 Set sh = Worksheets("Data") For Each cell In c If Application.CountIf(i, cell) 0 Then Range(cell, Cells(cell.Row, "G")).Copy sh.Cells(rw, 1) rw = rw + 1 End If Next End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanx....
But getting Application defined error or object defined error on this line LastRow = sh.Cells(Rows.Count, rw).End(xlUp).Row |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
rw was set to to so I originally used rw and then took out all the lines with
rw except this one from LastRow = sh.cells(rows.count,rw).end(xlup).row to LastRow = sh.cells(rows.count,"B").end(xlup).row "J.W. Aldridge" wrote: Thanx.... But getting Application defined error or object defined error on this line LastRow = sh.Cells(Rows.Count, rw).End(xlUp).Row |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
worked purfectly!
Thanx... When I become a millionaire, I'm buying you a Krystal! With Cheese! (Or a White Castle). |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Keep getting error with this part..... Range(cell, Cells(cell.Row, "g)).Copy sh.Cells(NewRow, 1) |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You change the B to a G and lost a double quote.
from Range(cell, Cells(cell.Row, "g)).Copy sh.Cells(NewRow, 1) to Range(cell, Cells(cell.Row, "g")).Copy sh.Cells(NewRow, 1) PS: I've been eating white castle for 50 years. I can eat a lot of those small burgers. "J.W. Aldridge" wrote: Keep getting error with this part..... Range(cell, Cells(cell.Row, "g)).Copy sh.Cells(NewRow, 1) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Code to copy and paste those cells that have data | Excel Programming | |||
Code to copy and paste those cells that have data | Excel Programming | |||
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... | Excel Programming | |||
Got the Copy/Cut Code But what is the Paste Code | Excel Programming | |||
VBA code gets lost from workbook if I paste in new data and save??? | Excel Programming |