LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default Table to sort via VBA but row&column size variable!

Tom, thank you.
Yes that solved the problem.
J_J

"Tom Ogilvy" wrote in message
...
Omitted the Underscore to make it a single command IF statement. Sorry.

Dim q as Long
For q=6 to 430
If Cells(q,"B").Text <"" then _
Cells(q,"A").Value="X"
Next

or using numbers specify the columns

Dim q as Long
For q=6 to 430
If Cells(q,2).Text <"" then _
Cells(q,1).Value="X"
Next

--
Regards,
Tom Ogilvy


"J_J" wrote in message
...
Tom,
For the loop you proposed I received a
"Next without For error" from the compiler.
J_J

"Tom Ogilvy" wrote in message
...
Dim q as Long
For q=6 to 430
If Cells(q,"B").Text <"" then
Cells(q,"A").Value="X"
Next

or using numbers specify the columns

Dim q as Long
For q=6 to 430
If Cells(q,2).Text <"" then
Cells(q,1).Value="X"
Next

--
Regards,
Tom Ogilvy


"J_J" wrote in message
...
Thank you Tom,

With great support from the NG, that part is OK now.
I have a simple follow-up Q. on the same code:

Range("A6:A430").Value = "X"

I need to change this code into something like this:

For q=6 to 430
If B(q)<"" then
A(q).Value="X"
Next

I am trying to set a loop to mark cells (A6:A430) with "X" for thouse
only
having a non empty cell nearby (B6:B430).

J_J


"Tom Ogilvy" wrote in message
...
Sub SortDataOnActiveSheet()
Dim cLastRow as Long, cLastCol as Long
Dim rng as Range
cLastRow = Cells(Rows.Count,"B").End(xlUp).Row
cLastCol = Cells(5,Columns.Count).End(xlToLeft).Column
Set rng = Range("B5",Cells(cLastRow,cLastCol))
rng..Sort Key1:=Range("B6"), Order1:=xlAscending, _
Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End Sub

would be about all you need to finish it.

--
Regards,
Tom Ogilvy


"J_J" wrote in message
...
Thank you Bob,
I wish I could finish the rest of the code...:)
J_J

"Bob Phillips" wrote in message
...

cLastRow = Cells(Rows.Count,"B").End(xlUp).Row
cLastCol = Cells(5,Columns.Count).End(xlToLeft).Column
Set rng = Range("B5",Cells(cLastRow,cLastCol)
rng.Sort etc.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"J_J" wrote in message
...
Hi,
I have a table in the region "B5:F130" where the cells B5, C5,

D5,
E5,
F5
represents the Data Labels and the rest downwords the data. I

want
to
sort
this table with referece to the numeric data in column B (which

are
in
region "B6:B130") with VBA coding. The problem is that, although
the
starting cell of this table is stable, but the number of rows
and
columns
of
this table may change. So the table may reside in B5:H140 or B5:
J150....etc
in the future. Thus I need to use an expression in the code so

that
sorting
of this table can be done whatever the row & column size is (of
course
not
exceeding excel limitations).
Can anyone suggest a code that will do that please?
Thank you in advance
J_J


















 
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
Lookup Multiple Values from a variable table size GCRDelphi Excel Worksheet Functions 1 August 5th 08 02:26 AM
Variable Column Sort Bernie New Users to Excel 1 December 29th 06 11:09 PM
different column size in a table Peyline Excel Worksheet Functions 4 July 10th 06 11:40 AM
How do I expand the column size on a Pivot Table using Excel 97? tamiller Excel Discussion (Misc queries) 1 January 4th 05 07:35 PM
Finding intersection of row and column (both variable) in table RangerAl Excel Worksheet Functions 8 January 1st 05 01:28 AM


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

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"