Replace value in worksheet vba

Darren Smith

Well-known Member
Joined
Nov 23, 2020
Messages
631
Office Version
  1. 2019
Platform
  1. Windows
Trying to replace a value with a different value in a column of a worksheet using a value from a combo box.
When I click the Combobox nothing happens?


VBA Code:
Private Sub Rear_Wheels_Click()

 Dim ws As Worksheet
 Set ws = ThisWorkbook.Worksheets("Job Card Master")
   
    Select Case Me.Rear_Wheels.Value
                  
              Case ("Double")
              
              ws.Range("E13:E299").Replace what:="Single", replacement:="Double"
                  
              Case ("Single")
              
              ws.Range("E13:E299").Replace what:="Double", replacement:="Single"
                  
              
              End Select
              

              
End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Here is how I wrote it:
VBA Code:
Private Sub Rear_Wheels_Click()
'Modified  4/21/2021  7:21:53 AM  EDT
Dim ws As Worksheet
 Set ws = ThisWorkbook.Worksheets("Job Card Master")
   With ws.Range("E13:E299")
        Select Case Me.Rear_Wheels.Value
                  
            Case ("Double")
                    .Replace what:="Single", replacement:="Double"
            Case ("Single")
                    .Replace what:="Double", replacement:="Single"
        End Select
    End With
    Rear_Wheels.ListIndex = -1
End Sub
 
Upvote 0
Sorry, still not working any chance I could send my workbook to you?
 
Upvote 0
Sorry, still not working any chance I could send my workbook to you?
What does not working mean?
What is it doing wrong?
Does it throw up a error message?
I never down load files posted on this forum
So in the Combobox you select Double then cell values should change to Single
 
Upvote 0
What does not working mean?
What is it doing wrong?
Does it throw up a error message?
I never down load files posted on this forum
So in the Combobox you select Double then cell values should change to Single That`s right then the same other way round
It`s not doing anything & there is no error massage?
 
Upvote 0
It`s not doing anything & there is no error massage?
So you are sure you have those values in the Range you showed in your script.
And you have the exact term Double and single loaded into the Combobox and you select Double or Single
And these values must be exact.
 
Upvote 0
I copied the value off the worksheet to the code. So could not be any different?
 
Upvote 0
I copied the value off the worksheet to the code. So could not be any different?
And your sure you have the correct values loaded into the Combobox.
You should select the value in the Combobox not enter the values manually into the Combobox
 
Upvote 0

Forum statistics

Threads
1,215,107
Messages
6,123,126
Members
449,097
Latest member
mlckr

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