Run macro without button

qxyy

New Member
Joined
Jan 19, 2021
Messages
2
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi teams, how can I run my macro without the button. Below is my script;)

Sub IF_Loop()

Dim cell As Range
For Each cell In Range("L12:AU3637")

If cell.Value Like "IMPORTANT" Then
cell.Interior.Color = 5296274
ElseIf cell.Value Like "NOT APPLICABLE" Then
cell.Interior.Color = 8421504

Else
cell.Interior.Color = 255

End If

Next cell

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim xSRg, xDRg, xISRg, xIDRg As Range
Dim xFNum As Long
On Error Resume Next
Set xSRg = Range("L12:L3637")
Set xDRg = Range("K12:K16")
For xFNum = 1 To xSRg.Count
Set xISRg = xSRg.Item(xFNum)
Set xIDRg = xDRg.Item(xFNum)
xIDRg.Interior.Color = xISRg.Interior.Color
Next xFNum

End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
1. Go to View Tab, Select Last Item Macros, View Macros, Select your Macro & Run.
2. If your Developer Tab is active go to that, Macros, Select your Macro & run
3. GO to VBA Window, Select Your macro to see it at right window. Click In code window to cursor see in it, Hit F5 or Go to Run Icon at the above panel.
 
Upvote 0

Forum statistics

Threads
1,214,556
Messages
6,120,190
Members
448,949
Latest member
keycalinc

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