Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting Excel spreadsheet where data exists

Status
Not open for further replies.

timotai

Technical User
Apr 13, 2002
119
0
0
GB
Hi

I have a database which creates a excel spreadsheet. I want to be able to format the colours of the spreadsheet cells fo rthe background and font. However the tricky bit is if there is data in a cell within a given range I want it to be one set of colours and where there is no data I want to use other colours.

I have tried a find but cannot get it to work, that was my desired option, I also tried to apply a conditional format but also cannot get that to work from access either.

I think my problem lies in an insufficient understanding of using VB to control Excel as an object.

All help is greatly greatly appreciated.

Thanks

Tim
 
Check out the UsedRange property of the worksheet object:
Code:
[green]'get address of first used cell[/green]
=Worksheets(1).UsedRange.Rows(1).Address
[green]'get address of last used cell[/green]
=Worksheets(1).UsedRange.Rows(Worksheets(1).UsedRange.Rows.Count).Address
[green]'select the used range[/green]
Worksheets(1).UsedRange.Select
[green]'set the backgound color[/green]
Worksheets(1).UsedRange.Interior.Color = RGB(100, 200, 100)

VBSlammer
redinvader3walking.gif

"You just have to know which screws to turn." - Professor Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top