VBA targeting only 2 columns

paul w

Board Regular
Joined
Apr 25, 2010
Messages
195
help required
Im using this code to insert a colon into a set of 4 numbers, and it works great but i only want it to check and change two columns, at the moment it checks and changes the whole sheet, how do i edit the code to only check colums 8 and 9.

Private Sub Worksheet_Change(ByVal Target As Range)
userinput = Target.Value
If userinput > 1 Then
newinput = Left(userinput, Len(userinput) - 2) & ":" & Right(userinput, 2)
Application.EnableEvents = False
Target = newinput
Application.EnableEvents = True
End If
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
thanks that worked i had been trying to mess with it (only way to learn i suppose) but couldnt get my head round it.
paul
 
Upvote 0

Forum statistics

Threads
1,215,135
Messages
6,123,238
Members
449,093
Latest member
Vincent Khandagale

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