ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying data at specific positions (https://www.excelbanter.com/excel-programming/350746-copying-data-specific-positions.html)

Sylvia[_18_]

Copying data at specific positions
 

Hi,

I want to write a macro for copying perticular cell from worksheet1 to
worksheet2 at some specified position only.
for instance: My data will be there only in the row 2 of Worksheet 1. I
want to search which cells contains the value and copy that value in the
row 1 of the worksheet2, but at the same column position. i.e. data of
column a2 (Worksheet 1) will be copied at a1 position in worksheet 2.
b2(Worksheet 1) to b1(Worksheet 2). g2(Worksheet 1) to g1(Worksheet 2)
and so on... If any cell is blank then ignore that.

Thanks,
Sylvia


--
Sylvia
------------------------------------------------------------------------
Sylvia's Profile: http://www.excelforum.com/member.php...o&userid=30300
View this thread: http://www.excelforum.com/showthread...hreadid=502395


Executor

Copying data at specific positions
 
Hi Sylvia,

I have cooked up:

Sub SylviasCopy()
Dim intLook As Integer
Dim intCol As Integer

intLook = 10

For intCol = 1 To 14
If Worksheets("Sheet1").Cells(2, intCol).Value = intLook Then
Worksheets("Sheet2").Cells(1, intCol).Value = intLook
' Exit For
End If
Next

End Sub

This will copy all valid values from sheet1 to sheet2
Top copy only the first valid value remove the character before Exit
For

Hoop this helps,

Executor



All times are GMT +1. The time now is 02:54 AM.

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