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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
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,213,510
Messages
6,114,037
Members
448,543
Latest member
MartinLarkin

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