Problem with my VBA

max4523

New Member
Joined
Mar 26, 2013
Messages
2
Could someone tell me what I'm doing wrong. I'm trying to have cells solve for the other and I'm failing.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column < 1 And Target.Column > 3 Then Exit Sub
Application.EnableEvents = False
Select Case Target.Column
Case Is = 1
If Target.Offset(0, -1) = "" Then
Application.EnableEvents = True
Exit Sub
Else: Target.Offset(0, 1) = (Target * 9.5)
End If
Case Is = 2
If Target.Offset(0, -2) = "" Then
Application.EnableEvents = True
Exit Sub
Else: Target.Offset(0, -2) = (Target / 9.5)
End If
End Select
Application.EnableEvents = True
End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Could it be this (Im no VBA expert)

Code:
If Target.Column < 1 And Target.Column > 3 Then Exit Sub

How can something be less than 1 AND greater than 3?
Shouldn't this be OR instead of AND?
 
Upvote 0

Forum statistics

Threads
1,202,902
Messages
6,052,451
Members
444,582
Latest member
Scramble

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