ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Copying and pasting with a macro (https://www.excelbanter.com/excel-discussion-misc-queries/257940-copying-pasting-macro.html)

Wombat

Copying and pasting with a macro
 
Hi!

I posted this up yesterday and am very pleased with the corrections I got. I
do have another question though:

How can I make it so that the copied information is inserted into sheet 2
and takes on the format of the target cell rather than keeping the original
one?


Sub Wombat()

Sheets("1").Cells(3, 12).Select
x = 3
y = 24
Do Until Cells(x, 12).Value = "END"
If Cells(x, 12).Value < "" Then
Cells(x, 12).Copy Sheets("2").Cells(y, 1)
x = x + 1
y = y + 1
Else
x = x + 1
End If
Loop

End Sub

Thanks in advance



Stefi

Copying and pasting with a macro
 
Replace
Cells(x, 12).Copy Sheets("2").Cells(y, 1)
by
Sheets("2").Cells(y, 1).Value = Cells(x, 12).Value


--
Regards!
Stefi



€˛Wombat€¯ ezt Ć*rta:

Hi!

I posted this up yesterday and am very pleased with the corrections I got. I
do have another question though:

How can I make it so that the copied information is inserted into sheet 2
and takes on the format of the target cell rather than keeping the original
one?


Sub Wombat()

Sheets("1").Cells(3, 12).Select
x = 3
y = 24
Do Until Cells(x, 12).Value = "END"
If Cells(x, 12).Value < "" Then
Cells(x, 12).Copy Sheets("2").Cells(y, 1)
x = x + 1
y = y + 1
Else
x = x + 1
End If
Loop

End Sub

Thanks in advance




All times are GMT +1. The time now is 11:39 PM.

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