VBA - Sub select all, but add exceptions

cozzagiorgi

New Member
Joined
Jun 27, 2018
Messages
41
Hi

I have this sub wich transforms all my unchecked boxes in checked boxes (R) in column B.


Code:
Sub allewählen()
 
Dim i As Long
Dim lastrow As Long
lastrow = Cells(Rows.Count, "B").End(xlUp).Row
 
    Range("B12:B" & lastrow).Value = "R" 'R = checkedbox
 
End Sub


How can I add exceptions to this sub?

Some rows will contain the value “S” and those should not be touched by this sub.
 
You start with
Code:
Evaluate(Replace("if(@=""S"",""S"",""R"")", [COLOR=#ff0000]"@"[/COLOR], [COLOR=#0000ff].Address[/COLOR]))
Replace replaces the part in red with the part in blue which gives
Code:
Evaluate("if(.address=""S"",""S"",""R"")")
. address is the address of the cell being looked at eg B12 which gives
Code:
if(B12=""S"",""S"",""R"")
ie a normal excel formula which is then calculated by evaluate
 
Upvote 0

Forum statistics

Threads
1,226,796
Messages
6,193,048
Members
453,772
Latest member
aastupin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top