ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   IF/THEN Statement - Simple Question.... (https://www.excelbanter.com/excel-programming/374709-if-then-statement-simple-question.html)

mvyvoda

IF/THEN Statement - Simple Question....
 
MSTeam,

I have a situation where a portion of a macro I have written adds a column
when ran. How can I create code that will check to see if this column is
already there so, if that portion of the macro see's this column, it does not
add a column. Here's what I have thus far (inserts colume and labels it
"Flagged"):

Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Range("B6").Select
ActiveCell.FormulaR1C1 = "Flagged"
With ActiveCell.Characters(Start:=1, Length:=7).Font
.Name = "Tahoma"
.FontStyle = "Bold"
.Size = 8
End With

Simple enough. I need something like an IF statement that checks if
"Flagged" exists and skips this portion of the code.

Thanks for all your time and energy,
-m

Charles Chickering

IF/THEN Statement - Simple Question....
 
If Range("B6") < "Flagged" Then
Columns("B").Insert
Range("B6").Value = "Flagged"
With ActiveCell.Characters(Start:=1, Length:=7).Font
.Name = "Tahoma"
.FontStyle = "Bold"
.Size = 8
End With
End If
--
Charles Chickering

"A good example is twice the value of good advice."


"mvyvoda" wrote:

MSTeam,

I have a situation where a portion of a macro I have written adds a column
when ran. How can I create code that will check to see if this column is
already there so, if that portion of the macro see's this column, it does not
add a column. Here's what I have thus far (inserts colume and labels it
"Flagged"):

Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Range("B6").Select
ActiveCell.FormulaR1C1 = "Flagged"
With ActiveCell.Characters(Start:=1, Length:=7).Font
.Name = "Tahoma"
.FontStyle = "Bold"
.Size = 8
End With

Simple enough. I need something like an IF statement that checks if
"Flagged" exists and skips this portion of the code.

Thanks for all your time and energy,
-m


mvyvoda

IF/THEN Statement - Simple Question....
 
Charles!!!!!

Thanks,
Mark

"Charles Chickering" wrote:

If Range("B6") < "Flagged" Then
Columns("B").Insert
Range("B6").Value = "Flagged"
With ActiveCell.Characters(Start:=1, Length:=7).Font
.Name = "Tahoma"
.FontStyle = "Bold"
.Size = 8
End With
End If
--
Charles Chickering

"A good example is twice the value of good advice."


"mvyvoda" wrote:

MSTeam,

I have a situation where a portion of a macro I have written adds a column
when ran. How can I create code that will check to see if this column is
already there so, if that portion of the macro see's this column, it does not
add a column. Here's what I have thus far (inserts colume and labels it
"Flagged"):

Columns("B:B").Select
Selection.Insert Shift:=xlToRight
Range("B6").Select
ActiveCell.FormulaR1C1 = "Flagged"
With ActiveCell.Characters(Start:=1, Length:=7).Font
.Name = "Tahoma"
.FontStyle = "Bold"
.Size = 8
End With

Simple enough. I need something like an IF statement that checks if
"Flagged" exists and skips this portion of the code.

Thanks for all your time and energy,
-m



All times are GMT +1. The time now is 07:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com