ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Modify to do to each required cell (https://www.excelbanter.com/excel-programming/416733-modify-do-each-required-cell.html)

Corey

Modify to do to each required cell
 
I have the below code that i made to change a the cell to the right to FontStrikeThrough IF the value to in tyhe cell was empty.
If it was not empty then the cell would Not be StrikeThrough

EG: The (6) in Cell D1 would be StrikeThrough as there is No value in C1.
The (5) is Normal Font as there IS a value in A1.

A B C D E F
1 10 5 6
2


I need to add to the below so it does the same to all these cells listed:
C100,E100,G100,I100..... AQ100
(Basically every 2nd Cell from C100 - AQ100)
How can i do this besides putting every cell in individually and running the code each time ?

~~~~~~~~~~~~~~~~~~~~~
Sub StrikeThrough()
With ActiveCell
If ActiveCell.Value = "" Then
ActiveCell.Offset(0, 1).Activate
With Selection.Font
.Strikethrough = True
End With
Else
ActiveCell.Offset(0, 1).Activate
With Selection.Font
.Strikethrough = False
End With
End If
End With
End
~~~~~~~~~~~~~~~~~~~~
--
Corey ....
The Silliest Question is generally
the one i forgot to ask.

Corey

Modify to do to each required cell
 
If i can get the same code to RUN 48 times then stop, that would solve it too?

"Corey" wrote in message ...
I have the below code that i made to change a the cell to the right to FontStrikeThrough IF the value to in tyhe cell was empty.
If it was not empty then the cell would Not be StrikeThrough

EG: The (6) in Cell D1 would be StrikeThrough as there is No value in C1.
The (5) is Normal Font as there IS a value in A1.

A B C D E F
1 10 5 6
2


I need to add to the below so it does the same to all these cells listed:
C100,E100,G100,I100..... AQ100
(Basically every 2nd Cell from C100 - AQ100)
How can i do this besides putting every cell in individually and running the code each time ?

~~~~~~~~~~~~~~~~~~~~~
Sub StrikeThrough()
With ActiveCell
If ActiveCell.Value = "" Then
ActiveCell.Offset(0, 1).Activate
With Selection.Font
.Strikethrough = True
End With
Else
ActiveCell.Offset(0, 1).Activate
With Selection.Font
.Strikethrough = False
End With
End If
End With
End
~~~~~~~~~~~~~~~~~~~~
--
Corey ....
The Silliest Question is generally
the one i forgot to ask.

joel

Modify to do to each required cell
 
I'm not sure if you are starting in column C or D because of the offset in
your code (0,1). Change start and end column as required.

Sub StrikeThrough()
For ColCount = Range("C100").column to Range("AQ100").column step 2
with Cells(100,ColCount)
If .Value = "" Then
.Font.Strikethrough = True
Else
.Font.Strikethrough = False
End If
End With
End


"Corey" wrote:

I have the below code that i made to change a the cell to the right to FontStrikeThrough IF the value to in tyhe cell was empty.
If it was not empty then the cell would Not be StrikeThrough

EG: The (6) in Cell D1 would be StrikeThrough as there is No value in C1.
The (5) is Normal Font as there IS a value in A1.

A B C D E F
1 10 5 6
2


I need to add to the below so it does the same to all these cells listed:
C100,E100,G100,I100..... AQ100
(Basically every 2nd Cell from C100 - AQ100)
How can i do this besides putting every cell in individually and running the code each time ?

~~~~~~~~~~~~~~~~~~~~~
Sub StrikeThrough()
With ActiveCell
If ActiveCell.Value = "" Then
ActiveCell.Offset(0, 1).Activate
With Selection.Font
.Strikethrough = True
End With
Else
ActiveCell.Offset(0, 1).Activate
With Selection.Font
.Strikethrough = False
End With
End If
End With
End
~~~~~~~~~~~~~~~~~~~~
--
Corey ....
The Silliest Question is generally
the one i forgot to ask


Corey

Modify to do to each required cell
 
Ended up placing the work STOP in Cell AS100 and using :

Do
With ActiveCell
If ActiveCell.Value = "" Then
ActiveCell.Offset(0, 1).Activate
With Selection.Font
.Strikethrough = True
End With
Else
ActiveCell.Offset(0, 1).Activate
With Selection.Font
.Strikethrough = False
End With
End If
End With
ActiveCell.Offset(0, 1).Activate
Loop Until ActiveCell.Value = "STOP"


Corey....

"Joel" wrote in message
...
I'm not sure if you are starting in column C or D because of the offset in
your code (0,1). Change start and end column as required.

Sub StrikeThrough()
For ColCount = Range("C100").column to Range("AQ100").column step 2
with Cells(100,ColCount)
If .Value = "" Then
.Font.Strikethrough = True
Else
.Font.Strikethrough = False
End If
End With
End


"Corey" wrote:

I have the below code that i made to change a the cell to the right to
FontStrikeThrough IF the value to in tyhe cell was empty.
If it was not empty then the cell would Not be StrikeThrough

EG: The (6) in Cell D1 would be StrikeThrough as there is No value in C1.
The (5) is Normal Font as there IS a value in A1.

A B C D E F
1 10 5 6
2


I need to add to the below so it does the same to all these cells listed:
C100,E100,G100,I100..... AQ100
(Basically every 2nd Cell from C100 - AQ100)
How can i do this besides putting every cell in individually and running
the code each time ?

~~~~~~~~~~~~~~~~~~~~~
Sub StrikeThrough()
With ActiveCell
If ActiveCell.Value = "" Then
ActiveCell.Offset(0, 1).Activate
With Selection.Font
.Strikethrough = True
End With
Else
ActiveCell.Offset(0, 1).Activate
With Selection.Font
.Strikethrough = False
End With
End If
End With
End
~~~~~~~~~~~~~~~~~~~~
--
Corey ....
The Silliest Question is generally
the one i forgot to ask




[email protected]

Modify to do to each required cell
 
On Sep 9, 2:49*pm, "Corey" wrote:
Ended up placing the work STOP in Cell AS100 and using :

Do
* *With ActiveCell
* * If ActiveCell.Value = "" Then
* * * * ActiveCell.Offset(0, 1).Activate
* * * * With Selection.Font
* * * * .Strikethrough = True
* * * * End With
* * * * Else
* * * * ActiveCell.Offset(0, 1).Activate
* * * * With Selection.Font
* * * * .Strikethrough = False
* * * * End With
* * * * End If
* * * * End With
* * * * ActiveCell.Offset(0, 1).Activate
* * Loop Until ActiveCell.Value = "STOP"

Corey....

"Joel" wrote in message

...



I'm not sure if you are starting in column C or D because of the offset in
your code (0,1). *Change start and end column as required.


Sub StrikeThrough()
* For ColCount = Range("C100").column to Range("AQ100").column step 2
* * *with Cells(100,ColCount)
* * * * *If .Value = "" Then
* * * * * * * *.Font.Strikethrough = True
* * * * *Else
* * * * * * * *.Font.Strikethrough = False
* * * * *End If
* *End With
End


"Corey" wrote:


I have the below code that i made to change a the cell to the right to
FontStrikeThrough IF *the value to in tyhe cell was empty.
If it was not empty then the cell would Not be StrikeThrough


EG: The (6) in Cell D1 would be StrikeThrough as there is No value in C1.
* * The (5) is Normal Font as there IS a value in A1.


* * * * A * * * *B * * * *C * * * *D * * * *E * * * *F
1 * *10 * * * *5 * * * * * * * * * *6
2


I need to add to the below so it does the same to all these cells listed:
C100,E100,G100,I100..... AQ100
(Basically every 2nd Cell from C100 - AQ100)
How can i do this besides putting every cell in individually and running
the code each time ?


~~~~~~~~~~~~~~~~~~~~~
Sub StrikeThrough()
* * With ActiveCell
* * If ActiveCell.Value = "" Then
* * * * ActiveCell.Offset(0, 1).Activate
* * * * With Selection.Font
* * * * .Strikethrough = True
* * * * End With
* * * * Else
* * * * ActiveCell.Offset(0, 1).Activate
* * * * With Selection.Font
* * * * .Strikethrough = False
* * * * End With
* * * * End If
* * End With
End
~~~~~~~~~~~~~~~~~~~~
--
Corey ....
The Silliest Question is generally
*the one i forgot to ask- Hide quoted text -


- Show quoted text -


Im not sure what you are trying to acheive, but if you would like
these cells to update dynamically you should use "Conditional
Formating".
Select the LEFT-MOST (cell eg. A2) that you want to behave in this way
ie. If cell to left = "" then this cell value should be displayed with
a strike through.
Go to FormatConditional Formating on the excel toobar.
Then change the drop down on the left to "FormulaIs" and then enter
the following formula in the box to the right (its like a RefEdit
control)" =A1=""
Instead of "A1" put the actual cell address for the cell to the left
of the cell you want. Do not use the $ sign in this case.
Press ok.
Test the formatting by placing and removing a value in the A1 cell.
If it works then select the A2 cell and click and hold the mouse down
on the bottom right hand corner and drag the cell as far to the right/
down as you want.
If you're using Excel 2003 then you should see a "Smart tag" to the
right of the range you have just filled over, click this and select
"Fill Formatting Only"
I hope this helps, I may have misunderstood what you are trying to do.
But this will update on the fly, ie. you wont have to run the macro
each time the cell values change...
Bernie


All times are GMT +1. The time now is 09:55 PM.

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