LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to determine the end range in my code....

With the format of the Excel worksheet as follow:
memberID----Q1-------*Q2-------Q4
123456 yes car yes
plane
people
234578 no boat no
people
784528 yes car yes
boat

I want to transform it to the following format:
memberID----Q1----car----plane----boat----people----Q4
123456 yes car plane people yes
234578 no boat people no
784529 yes car boat
yes

The following is the code I created, somehow I can't figure out how to set
the end range to the next member ID for the 'InnerNumRows"
Sub Test()
Dim x As Integer
Dim y As Integer
' Set numrows = number of rows of data, use the column with the maximum
of rows.
NumRows = Range("C2", Range("C2").End(xlDown)).Rows.Count
Debug.Print NumRows
' Select first line of data.
Range("A2").Select
For x = 1 To NumRows
' Number of rows to the next member ID.
InnerNumRows = Range(ActiveCell, ActiveCell.Next(4)).Rows.Count
Debug.Print InnerNumRows
For y = 1 To InnerNumRows
' Check active cell for search value.
Select Case ActiveCell.Offset(0, 2).Value
Case "car"
ActiveCell.Offset(0, 2).Cut
Destination:=ActiveCell.Offset(1 - y, 2)
Case "plane"
ActiveCell.Offset(0, 2).Cut
Destination:=ActiveCell.Offset(1 - y, 3)
Case "boat"
ActiveCell.Offset(0, 2).Cut
Destination:=ActiveCell.Offset(1 - y, 4)
Case "people"
ActiveCell.Offset(0, 2).Cut
Destination:=ActiveCell.Offset(1 - y, 5)
End Select
' Step down 1 row from present location.
ActiveCell.Offset(1, 0).Select
Next
' Selects cell down 1 row from active cell.
ActiveCell.Offset(1, 0).Select
Next

End Sub

Thanks




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB code to determine address of activeworkbook Kevin Excel Discussion (Misc queries) 2 January 5th 08 01:57 AM
Determine if range has NO Blank Cells without looping through each cell in range Excelenator[_29_] Excel Programming 4 August 4th 06 06:30 AM
Code to determine if a cell contains an array function? [email protected] Excel Discussion (Misc queries) 1 August 29th 05 10:35 PM
I need to use area code to determine time zone Dick Excel Discussion (Misc queries) 1 July 11th 05 05:31 PM
Code to determine name of Worksheet Ant Excel Discussion (Misc queries) 6 May 24th 05 01:57 PM


All times are GMT +1. The time now is 12:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"