ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How to copy some text in columns and rest in rows (https://www.excelbanter.com/excel-discussion-misc-queries/106116-how-copy-some-text-columns-rest-rows.html)

Greg

How to copy some text in columns and rest in rows
 
Hi I have an excel table that has water quality data for numerous sites in
about a dozen columns eg. pH, salinity, turbidity , to put it in a database I
need to cut and paste it so that for each of these parameters, the site name,
code and date/time is in the same row.
Eg. Now it is: Site Code Date/Time pH Turbidity Salinity
I would like:
Site Code Date/Time pH
Site Code Date/Time Turbidity
Site Code Date/Time Salinity
Any help would be very much appreciated.
Thanks.
Cheers,
Greg

raypayette

How to copy some text in columns and rest in rows
 

Sub DBprep()
Worksheets(1).Select
j = 1
For i = 2 To 4
Worksheets(1).Select
s = Cells(i, 1).Text
c = Cells(i, 2).Value
d = Cells(i, 3).Value
p = Cells(i, 4).Value
t = Cells(i, 5).Value
s2 = Cells(i, 6).Value
Worksheets(2).Select
j = j + 1
Cells(j, 1).Value = s
Cells(j, 2).Value = c
Cells(j, 3).Value = d
Cells(j, 4).Value = p
j = j + 1
Cells(j, 1).Value = s
Cells(j, 2).Value = c
Cells(j, 3).Value = d
Cells(j, 4).Value = t
j = j + 1
Cells(j, 1).Value = s
Cells(j, 2).Value = c
Cells(j, 3).Value = d
Cells(j, 4).Value = s2
Next
End Sub


--
raypayette


------------------------------------------------------------------------
raypayette's Profile: http://www.excelforum.com/member.php...o&userid=29569
View this thread: http://www.excelforum.com/showthread...hreadid=573651


Greg

How to copy some text in columns and rest in rows
 
Thanks heaps,
that's worked a treat I think.


All times are GMT +1. The time now is 08:20 PM.

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