Need to write function that will change column width based on a condition

D

dunlapww

Subject says it all, is this a VBA thing or some function I have yet
to discover in the function list. I have no idea how to write this in
VBA. If anyone has any ideas I'd greatly appreciate it. Thanks, Will
 
J

JE McGimpsey

Functions, even user defined functions, can only return values to their
calling cells. They can't change cell or worksheet formatting.

You may be able to do what you want with an event macro, but how to
implement it would depend on the condition you want to use.
 
J

Joel

You can't change column width inside a function. Only a macro will do it
which means you have either manual activate it or have it in a
Worksheet_Change()
macro.

Sub Worksheet_Change(Target as Range)

if target <> 1000 then
Target.ColumnWidth = 15
end if

end sub
 
Top