PC Review


Reply
Thread Tools Rate Thread

Change from row to colume n colume to row

 
 
nirupreddys@gmail.com
Guest
Posts: n/a
 
      4th Oct 2007
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

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      4th Oct 2007
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)

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
kohir
Guest
Posts: n/a
 
      4th Oct 2007
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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Colume Headings Gu y Microsoft Excel Worksheet Functions 1 30th Nov 2007 12:40 PM
How to change color of colume letter and row number? =?Utf-8?B?REs=?= Microsoft Excel Misc 1 6th Jun 2007 08:33 PM
3 COLUME CHART =?Utf-8?B?QkFORElU?= Microsoft Excel Worksheet Functions 0 21st Mar 2006 07:17 PM
How can I look up max of one colume and display the colume to the. =?Utf-8?B?QnJpYW4gQ29ybmVqbw==?= Microsoft Excel Worksheet Functions 2 21st Feb 2005 05:47 AM
add a value to a colume =?Utf-8?B?YSBqb2huc29u?= Microsoft Access Getting Started 1 23rd Nov 2004 05:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:53 AM.