ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Trouble with a macro - copying cells (https://www.excelbanter.com/excel-programming/298941-trouble-macro-copying-cells.html)

ToddG[_3_]

Trouble with a macro - copying cells
 
Having trouble coming up with a macro to do the following:

If any cell in column A of sheet "Export" = "PKG",
Copy the cells in columns A, B, & L in that row to cells
A, C, & F of sheet "Labor Costing" respectively, starting
at Row 24 (of sheet "Labor Costing").

Kind of hard to explain, if you need more info let me know.

Any help would be appreciated,

TIA,
Todd

Frank Kabel

Trouble with a macro - copying cells
 
Hi
as a starting point:
http://www.rondebruin.nl/copy5.htm

--
Regards
Frank Kabel
Frankfurt, Germany


ToddG wrote:
Having trouble coming up with a macro to do the following:

If any cell in column A of sheet "Export" = "PKG",
Copy the cells in columns A, B, & L in that row to cells
A, C, & F of sheet "Labor Costing" respectively, starting
at Row 24 (of sheet "Labor Costing").

Kind of hard to explain, if you need more info let me know.

Any help would be appreciated,

TIA,
Todd


Bob Phillips[_6_]

Trouble with a macro - copying cells
 
Not tested, but try this

Set oCell = Columns("A:A").Find("PKG")
If Not oCell Is Nothing Then
Range("A" & oCell.Row).Copy Worksheets("Labor Costing").Range("A24")
Range("B" & oCell.Row).Copy Worksheets("Labor Costing").Range("C24")
Range("L & oCell.Row).Copy Worksheets("Labor Costing").Range("F24")
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"ToddG" wrote in message
...
Having trouble coming up with a macro to do the following:

If any cell in column A of sheet "Export" = "PKG",
Copy the cells in columns A, B, & L in that row to cells
A, C, & F of sheet "Labor Costing" respectively, starting
at Row 24 (of sheet "Labor Costing").

Kind of hard to explain, if you need more info let me know.

Any help would be appreciated,

TIA,
Todd




Bob Phillips[_6_]

Trouble with a macro - copying cells
 
Slight type

Set oCell = Columns("A:A").Find("PKG")
If Not oCell Is Nothing Then
Range("A" & oCell.Row).Copy Worksheets("Labor
Costing").Range("A24")
Range("B" & oCell.Row).Copy Worksheets("Labor
Costing").Range("C24")
Range("L" & oCell.Row).Copy Worksheets("Labor
Costing").Range("F24")
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bob Phillips" wrote in message
...
Not tested, but try this

Set oCell = Columns("A:A").Find("PKG")
If Not oCell Is Nothing Then
Range("A" & oCell.Row).Copy Worksheets("Labor

Costing").Range("A24")
Range("B" & oCell.Row).Copy Worksheets("Labor

Costing").Range("C24")
Range("L & oCell.Row).Copy Worksheets("Labor

Costing").Range("F24")
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"ToddG" wrote in message
...
Having trouble coming up with a macro to do the following:

If any cell in column A of sheet "Export" = "PKG",
Copy the cells in columns A, B, & L in that row to cells
A, C, & F of sheet "Labor Costing" respectively, starting
at Row 24 (of sheet "Labor Costing").

Kind of hard to explain, if you need more info let me know.

Any help would be appreciated,

TIA,
Todd






ToddG

Trouble with a macro - copying cells
 
Hi Bob,

Thanks for your reply. This code works except that it only
works for the first row that it finds "PKG". I need it to
look at ALL rows for "PKG" in column M and then run your
code for each row that it finds "PKG".

Thanks again
-----Original Message-----
Slight type

Set oCell = Columns("A:A").Find("PKG")
If Not oCell Is Nothing Then
Range("A" & oCell.Row).Copy Worksheets("Labor
Costing").Range("A24")
Range("B" & oCell.Row).Copy Worksheets("Labor
Costing").Range("C24")
Range("L" & oCell.Row).Copy Worksheets("Labor
Costing").Range("F24")
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bob Phillips" wrote

in message
...
Not tested, but try this

Set oCell = Columns("A:A").Find("PKG")
If Not oCell Is Nothing Then
Range("A" & oCell.Row).Copy Worksheets("Labor

Costing").Range("A24")
Range("B" & oCell.Row).Copy Worksheets("Labor

Costing").Range("C24")
Range("L & oCell.Row).Copy Worksheets("Labor

Costing").Range("F24")
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing

direct)

"ToddG" wrote in

message
...
Having trouble coming up with a macro to do the

following:

If any cell in column A of sheet "Export" = "PKG",
Copy the cells in columns A, B, & L in that row to

cells
A, C, & F of sheet "Labor Costing" respectively,

starting
at Row 24 (of sheet "Labor Costing").

Kind of hard to explain, if you need more info let me

know.

Any help would be appreciated,

TIA,
Todd





.


ToddG

Trouble with a macro - copying cells
 
Thanks very much for the link Frank...Great page. I'll
take a look at it.

Thanks again,
Todd
-----Original Message-----
Hi
as a starting point:
http://www.rondebruin.nl/copy5.htm

--
Regards
Frank Kabel
Frankfurt, Germany


ToddG wrote:
Having trouble coming up with a macro to do the

following:

If any cell in column A of sheet "Export" = "PKG",
Copy the cells in columns A, B, & L in that row to cells
A, C, & F of sheet "Labor Costing" respectively,

starting
at Row 24 (of sheet "Labor Costing").

Kind of hard to explain, if you need more info let me

know.

Any help would be appreciated,

TIA,
Todd

.


Bob Phillips[_6_]

Trouble with a macro - copying cells
 
Dim iRow As Long

Sub CopyData()
Dim oCell As Range, sFirst

iRow = 24
With Columns("A:A")
Set oCell = .Find("PKG")
If Not oCell Is Nothing Then
sFirst = oCell.Address
Do
CopyCells oCell
Set oCell = .FindNext(oCell)
Loop While Not oCell Is Nothing And _
oCell.Address < sFirst
End If
End With

End Sub

Sub CopyCells(rng As Range)

Range("A" & rng.Row).Copy _
Worksheets("Labor Costing").Range("A" & iRow)
Range("B" & rng.Row).Copy _
Worksheets("Labor Costing").Range("C" & iRow)
Range("L" & rng.Row).Copy _
Worksheets("Labor Costing").Range("F" & iRow)

iRow = iRow + 1

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"ToddG" wrote in message
...
Hi Bob,

Thanks for your reply. This code works except that it only
works for the first row that it finds "PKG". I need it to
look at ALL rows for "PKG" in column M and then run your
code for each row that it finds "PKG".

Thanks again
-----Original Message-----
Slight type

Set oCell = Columns("A:A").Find("PKG")
If Not oCell Is Nothing Then
Range("A" & oCell.Row).Copy Worksheets("Labor
Costing").Range("A24")
Range("B" & oCell.Row).Copy Worksheets("Labor
Costing").Range("C24")
Range("L" & oCell.Row).Copy Worksheets("Labor
Costing").Range("F24")
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bob Phillips" wrote

in message
...
Not tested, but try this

Set oCell = Columns("A:A").Find("PKG")
If Not oCell Is Nothing Then
Range("A" & oCell.Row).Copy Worksheets("Labor

Costing").Range("A24")
Range("B" & oCell.Row).Copy Worksheets("Labor

Costing").Range("C24")
Range("L & oCell.Row).Copy Worksheets("Labor

Costing").Range("F24")
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing

direct)

"ToddG" wrote in

message
...
Having trouble coming up with a macro to do the

following:

If any cell in column A of sheet "Export" = "PKG",
Copy the cells in columns A, B, & L in that row to

cells
A, C, & F of sheet "Labor Costing" respectively,

starting
at Row 24 (of sheet "Labor Costing").

Kind of hard to explain, if you need more info let me

know.

Any help would be appreciated,

TIA,
Todd




.





All times are GMT +1. The time now is 12:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com