Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Count Ranges Q | Excel Worksheet Functions | |||
Count age ranges | Excel Worksheet Functions | |||
count age ranges | Excel Discussion (Misc queries) | |||
count if in two ranges | Excel Discussion (Misc queries) | |||
count date ranges | Excel Worksheet Functions |