View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Set formatting variable

Hi Sige,

The following does, I think, what you ask. However, this may well not be
what you intend.

Perhaps, therefore, it might be worthwhile explaining what it is that you
are trying to achieve and, possibly, why.

My code may well be susceptible to significant simplification, but my
incertitude as to your aims precludes me from investigation,

'=============
Public Sub Tester()
Dim rng1 As Range
Dim rng2 As Range
Dim LastCol As Long
Dim lastRow As Long

Set rng1 = ActiveSheet.UsedRange
With rng1
LastCol = .Columns(.Columns.Count).Column

lastRow = .Rows.Count - .Row + 1
End With

If LastCol 8 Then
Set rng2 = Range("A1", _
Cells(lastRow, rng1.Columns(2).Column))
Else
Set rng2 = Range("A1:H2")
End If
With rng2
.Interior.ColorIndex = 1
.Font.ColorIndex = 2
End With
End Sub
'<<=============

---
Regards,
Norman



"Sige" wrote in message
oups.com...
Hi All,

Can I set Range A1:H2 with Formatting:
interior color =Black, font =White?

...
But if Usedrange.column H then Set Formatting
on Range:A1:Usedrange.column2

if usedrange.column<H then keep range A1:H2

Brgds Sige