ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy to (https://www.excelbanter.com/excel-programming/405787-copy.html)

Robert[_30_]

Copy to
 
Hello,

Further to my previous post I am again stucked with a command.
With the below statement I want to copy certain lines to a different
sheet, but as I have to use this statement a couple of times.
Therefore I would like to be flexible in choosing the cell to which I
would like to copy the selected lines.

In the current statement all results are copied to column G so in case
of multiple selections the system will overwrite the date in cell G1.
Can anyone advice how to adjust this statement in order to get all
values past starting in cell G20?

Hope it makes sense;-)

Thanks very much!!

Rgds,
robert

'Subtract: RNFH, PRIVATE LOANS (i=b)
Dim bLastRow As Long, bNextRow As Long
Dim b As Long
With Worksheets("Cut-Out")
bLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For b = 1 To bLastRow
If .Cells(b, "A").Value = "RNFH" Then
bNextRow = bNextRow + 1
.Cells(b, "A").Resize(, 28).Copy _
Worksheets("BarraFormat").Cells(aNextRow, "G")
End If
Next b

End With

John

Copy to
 
not sure if I have fully understood you but following correction to your code
should paste results in col G Row 20 onward:

'Subtract: RNFH, PRIVATE LOANS (i=b)
Dim bLastRow As Long, bNextRow As Long
Dim b As Long
bNextRow = 20
With Worksheets("Cut-Out")
bLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For b = 1 To bLastRow
If .Cells(b, "A").Value = "RNFH" Then
.Cells(b, "A").Resize(, 28).Copy _
Worksheets("BarraFormat").Cells(bNextRow, "G")
bNextRow = bNextRow + 1
End If
Next b
End With


--
JB


"Robert" wrote:

Hello,

Further to my previous post I am again stucked with a command.
With the below statement I want to copy certain lines to a different
sheet, but as I have to use this statement a couple of times.
Therefore I would like to be flexible in choosing the cell to which I
would like to copy the selected lines.

In the current statement all results are copied to column G so in case
of multiple selections the system will overwrite the date in cell G1.
Can anyone advice how to adjust this statement in order to get all
values past starting in cell G20?

Hope it makes sense;-)

Thanks very much!!

Rgds,
robert

'Subtract: RNFH, PRIVATE LOANS (i=b)
Dim bLastRow As Long, bNextRow As Long
Dim b As Long
With Worksheets("Cut-Out")
bLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For b = 1 To bLastRow
If .Cells(b, "A").Value = "RNFH" Then
bNextRow = bNextRow + 1
.Cells(b, "A").Resize(, 28).Copy _
Worksheets("BarraFormat").Cells(aNextRow, "G")
End If
Next b

End With



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

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