![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Join Date: Mar 2004
Posts: 15
|
Awright, I'm just getting frustrated here.
I want to start in cell A1 and working my way down the column locate the next used cell. So if cells A3, A7, and A98 have data my psuedo code would be like The data looks like Col A ColB Test data data Another more more more And more again sorry the post didn't space things as expected I know how to use offset. I have tried using .end(xldown) to get to the next data point in column A, but I keep getting unexpected results. |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,738
|
Try using SpecialCells
Dim Rng As Range Set Rng = Range("A:A").SpecialCells(xlCellTypeConstants) or more specific Set Rng = Range("A:A").SpecialCells(xlCellTypeConstants,xlTextValues) |
|
|
|
|
|
#3 |
|
Join Date: Mar 2004
Posts: 15
|
Thanks, not quite the effect I wanted, but still good to know.
|
|
|
|
|
|
#4 |
|
MrExcel MVP
Admin Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,617
|
If your data looks like:
Code:
ColA ColB GroupA (Empty) (Empty) Member1 (Empty) Member2 GroupB (Empty) (Empty) Member2 (Empty) Member3 Set Rng = Range("A:A").SpecialCells(xlvisible) |
|
|
|
|
|
#5 |
|
Join Date: Mar 2004
Posts: 15
|
I ended up with looping through all the cells in A and B
If A is empty go looking for B and hang on to the last known A value. Do this until B is empty. Then go back and look for the next A and do it all over again. Works. Ain't pretty, but it works. |
|
|
|
|
|
#6 |
|
MrExcel MVP
Admin Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,617
|
I still vote for an autofilter. E.g.,
http://www.mrexcel.com/board2/viewto...=77261&start=8 These are easy, turn on your macro recorder for the syntax. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|