![]() |
Change from row to colume n colume to row
Hi,
I am New to excel programing in VB, I want to know the code how to change the row to colume and colume to row for eg if i have : abc 1 2 3 xyz 2 3 5 hgf 3 4 3 and i have a button call CHANGE when i click on the button CHANGE the data should be viewed as below abc 1 abc 2 abc 3 xyz 2 xyz 3 xyz 5 hgf 3 hgf 4 hgf 3 can anyone let me know the code and can i can i know where i lean online for programing in VB Thanks in advance Regards |
Change from row to colume n colume to row
Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit Dim i As Long, j As Long Dim iLastRow As Long Dim iLastCol As Long With ActiveSheet iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row For i = iLastRow To 1 Step -1 iLastCol = .Cells(i, .Columns.Count).End(xlToLeft).Column If iLastCol 1 Then .Rows(i + 1).Resize(iLastCol - 2).Insert .Cells(i + 1, "A").Resize(iLastCol - 2).Value = .Cells(i, "A").Value For j = 3 To iLastCol .Cells(i + j - 2, "B").Value = .Cells(i, j).Value .Cells(i, j).Value = "" Next j End If Next i End With End Sub -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) wrote in message ups.com... Hi, I am New to excel programing in VB, I want to know the code how to change the row to colume and colume to row for eg if i have : abc 1 2 3 xyz 2 3 5 hgf 3 4 3 and i have a button call CHANGE when i click on the button CHANGE the data should be viewed as below abc 1 abc 2 abc 3 xyz 2 xyz 3 xyz 5 hgf 3 hgf 4 hgf 3 can anyone let me know the code and can i can i know where i lean online for programing in VB Thanks in advance Regards |
Change from row to colume n colume to row
Thanx Bob for your help,
However can I have a code which is like vice versa... mean for eg if i have : abc 1 abc 2 abc 3 xyz 2 xyz 3 xyz 5 hgf 3 hgf 4 hgf 3 and i have a button call CHANGE when i click on the button CHANGE abc 1 2 3 xyz 2 3 5 hgf 3 4 3 and when i have something like this abc 1 2 3 xyz 2 3 5 hgf 3 4 3 and i have a button call CHANGE when i click on the button CHANGE abc 1 abc 2 abc 3 xyz 2 xyz 3 xyz 5 hgf 3 hgf 4 hgf 3 hope you have understood what i ment... like vice versa Thank you in advance Regards |
All times are GMT +1. The time now is 03:53 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com