selection.interior

G

Guest

Ok, I'm totally new to VBA but am learning fast. I created two macros. One
that simply colors certain text and cells white - so they dont print. And
then another that changes the text back to black and then highlights a few
cells. They're basically my show/hide buttons for text I dont want to print.

However, whenever I run the macro it hangs up on the last line of the macro
"selection.interior.colorindex = x".
Also, will this macro run on all platforms? Is there something I need to
know about VBA for Excel on a Mac versus PC?


Sub Hide_Text()
Range("g11:k61").Select
Selection.Font.ColorIndex = 2
Range("g12:g61,a12:e61,l8").Select
Selection.Interior.ColorIndex = 2
End Sub

Sub Show_Text()
Range("a11:m11,g11:k61").Select
Selection.Font.ColorIndex = 0
Range("g12:g61,b12:e61,l8").Select
Selection.Interior.ColorIndex = 19
End Sub
 
L

Leith Ross

Hello Eric ,

The problem is with your range assignment...
Range("g12:g61,a12:e61,l8").Select

This type of Range statement can only accept 2 arguments separated by
comma.
Range("G12:G61", "A12:E61").Select

This will select A12 as the Top Left cell in the Range and G61 as th
Lower Right in the Range rectangle .

Before I go on, it would help to know how you want the cells selected
As 3 separate Ranges or what? Let me know.

Thanks,
Leith Ros
 
G

Guest

What I'm trying to do is create two buttons: Show Text/Hide Text.

The Show Text button turns the text in the ranges black and then turns the
interiors of that selection yellow - to highlight where the user should input
data.

The Hide Text button then turns both the text and interiors white so they
dont print.

There are two separate ranges I need to effect. Though I'd like the option
to include other ranges at a later date.

As it works now I have to manually select the ranges and do the hide/show...
it'd save some headaches to be able to assign this to a button, since the
ranges are fixed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top