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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Excel with/end with problem

Status
Not open for further replies.

knifey

Technical User
Nov 14, 2006
180
GB
Hi,
I have a simple with/end with to turn text red and bold. But the code turns the active cell red and bold instead.
Can anyone give me any advice on where I'm going wrong?
Thanks,
Roy

jobname = Trim(c.Offset(0, 12).Value)
With jobname
Selection.Font.ColorIndex = 3
Selection.Font.Bold = True
End With
 
Because you are using SELECTION

what cell are you trying to change ?

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Hi Geoff,
I'm trying to change every cell in column M (c offset 12 columns, where c is column A1, A2, etc.).
Thanks,
Roy
 
Seems like you have a loop going opn outside of the posted code.

If you are using a

For each c in Range

type construct, you need to use c to define which cell to change

with c.offset(0,12)
.Font.ColorIndex = 3
.Font.Bold = True
end with


Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Hi Geoff,
Thanks for the info. I tried that code first but I had left off the '.' before Font!
I feel somewhat a plank.
Cheers,
Roy
 



"...somewhat a plank."

Don't feel so board with yourself! ;-)

Skip,

[glasses] When a wee mystic is on the loose..
It's a Small Medium at Large! [tongue]
 
Don't worry about it - very common issue

As long as you can see the wood for the trees you'll be fine ;-)

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 



Don't cellulose short.

Skip,

[glasses] When a wee mystic is on the loose..
It's a Small Medium at Large! [tongue]
 
Sometimes Skip makes you pay for the help in groans. [wink]

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 



...after all, I'm a groan-up.

Skip,

[glasses] When a wee mystic is on the loose..
It's a Small Medium at Large! [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top