LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default count if and format ranges

Glad I could help. Goodness knows I've received tons of help from this forum
to get to where I am now.

Thanks for rating the post, too.

Matthew Pfluger

"SLW612" wrote:

Terrific! I can work with this. I was having trouble getting the count of
non-blank cells and then turning that into a number I could use, but I think
this will be perfect. Thanks for your help!

"Matthew Pfluger" wrote:

Perhaps this is more what you mean.

Sub GetRangeToFormat()

' Get range to count
Dim rCountRange As Range
Set rCountRange = Selection.Offset(2, 0).Resize(8, 25)
rCountRange.Select

' Get range to count rows
Dim rColToCount As Range
Set rColToCount = rCountRange.Columns(6)
rColToCount.Select

' Count rows
Dim NumRows As Integer
NumRows = Application.WorksheetFunction.CountA(rColToCount)

' Get range to count columns
Dim rRowtoCount As Range
Set rRowtoCount = rCountRange.Rows(1).Offset(-2, 0)
rRowtoCount.Select

' Count columns
Dim NumCol As Integer
NumCol = Application.WorksheetFunction.CountA(rRowtoCount)

' Get range to format
Dim rRangeToFormat As Range
Set rRangeToFormat = Range(rCountRange.Cells(1, 1),
rCountRange.Cells(NumRows, NumCol + 8))
rRangeToFormat.Select

' Select first column
rRangeToFormat.Columns(1).Select

' Apply formatting

End Sub

You may have to modify the selections a bit to tweak it to what you want,
but I think that should work well. I tested it on a workbook similar to what
you describe in your post.

Tip: To make the final version run quicker, remove all lines containing
xRange.Select.

HTH,
Pflugs

 
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
Count Ranges Q Seanie Excel Worksheet Functions 2 January 15th 09 04:20 PM
Count age ranges James Excel Worksheet Functions 8 November 9th 07 08:04 PM
count age ranges Clash Excel Discussion (Misc queries) 3 June 13th 06 03:05 PM
count if in two ranges TUNGANA KURMA RAJU Excel Discussion (Misc queries) 0 October 8th 05 04:47 AM
count date ranges murtaza Excel Worksheet Functions 4 July 18th 05 04:29 PM


All times are GMT +1. The time now is 02:07 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"