Putting conditional formatting on a page after it's created in vba

kadain

New Member
Joined
May 19, 2022
Messages
22
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hi guys am looking to code in a condictional formatting to a newly created sheet via vba
This intales highlighting the row orange when you click on a cell between a certain range(Any range will do ill edit it to what i need)
i would just set it up when i use it my self manually but unfortantly the workbooks is for other peoples use and they are not excel friendly
Please any help would be great
 
Your private sub looks like is causing wrong behavior of this sub
yeah i think your right cause i fixed the other sheet by changing the range to
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim testRange As Range
Dim myRange As Range
Dim selectedRow As Long
Set testRange = Range("$A$1:$O$5000")
Set myRange = Selection
If Not Intersect(testRange, myRange) Is Nothing Then
selectedRow = ActiveCell.Row
ActiveSheet.Rows.Interior.Color = xlNone '<== optional
ActiveSheet.Rows(selectedRow).Interior.Color = RGB(255, 192, 0)
End If
End Sub
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Your private sub looks like is causing wrong behavior of this sub
yes i think your right am trying to intergrate the two of them but having no luck the other bit of code i used is

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("C2")) Is Nothing Then ProductCode
End Sub
 
Upvote 0
yes i think your right am trying to intergrate the two of them but having no luck the other bit of code i used is

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("C2")) Is Nothing Then ProductCode
End Sub
For me it's working fine. I cannot understand the problem. Could you explain it better?
 

Attachments

  • Capture.JPG
    Capture.JPG
    128.4 KB · Views: 5
Upvote 0
on the sheet am adding your code too, it already has a private sub for the sheet to do some function
i think the priavte sub the sheet has already :
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("C2")) Is Nothing Then ProductCode
End Sub
is interfering with your code and causing it to debug
 
Upvote 0
on the sheet am adding your code too, it already has a private sub for the sheet to do some function
i think the priavte sub the sheet has already :
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("C2")) Is Nothing Then ProductCode
End Sub
is interfering with your code and causing it to debug
show the error
 
Upvote 0

Forum statistics

Threads
1,216,747
Messages
6,132,486
Members
449,729
Latest member
davelevnt

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