Help with VBA code

APML

Board Regular
Joined
Sep 10, 2021
Messages
216
Office Version
  1. 365
Hi All, I have the following code, which I've tried to join from 3 separate codes, there is an issue with it, was hoping someone would be able to help me.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Update the named range "CurrentRow_Pivot" whenever the selection changes
With ThisWorkbook.Names("CurrentRow_Pivot")
.Name = "CurrentRow_Pivot"
.RefersToR1C1 = "=" & ActiveCell.Row
End With
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
'Activate the sheet with the same name as the value entered in cell C5
On Error Resume Next
If Not (Application.Intersect(Range("C5"), Target) Is Nothing) Then
ThisWorkbook.Sheets(Target.Value).Activate
End If

'Convert any data entered in cell A1 to uppercase
If Target.Address = "CodePivotPoints" Then
Target.Value = UCase(Target.Value)
End If
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Depends on what you're trying to do. Worksheet_Change and Worksheet_SelectionChage kind of conflict.
 
Upvote 0
Depends on what you're trying to do. Worksheet_Change and Worksheet_SelectionChage kind of conflict.
Thx for helping me:
This highlights the current row
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Update the named range "CurrentRow_Pivot" whenever the selection changes
With ThisWorkbook.Names("CurrentRow_Pivot")
.Name = "CurrentRow_Pivot"
.RefersToR1C1 = "=" & ActiveCell.Row
End With
End Sub

This is a pull down list that takes me to other sheets within the workbook
Private Sub Worksheet_Change(ByVal Target As Range)
'Activate the sheet with the same name as the value entered in cell C5
On Error Resume Next
If Not (Application.Intersect(Range("C5"), Target) Is Nothing) Then
ThisWorkbook.Sheets(Target.Value).Activate
End If

This makes sure that anything put into cell named CodePivotPoints converts to uppercase
'Convert any data entered in cell A1 to uppercase
If Target.Address = "CodePivotPoints" Then
Target.Value = UCase(Target.Value)
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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