Using VBA to change cell focus several times on condition

JKSteed

New Member
Joined
Jan 2, 2013
Messages
1
I am trying to get VBA to change the cell focus on the sheet. I can get it to work with one condition, but not two or more.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("c2:c5000")) Is Nothing Then Target(1, 8).Select

If Not Intersect(Target, Range("h2:h5000")) Is Nothing Then
Target(2, -6).Select
End If
End Sub

But this doesn't do what I want.

Here's what I want:
1. User enters data into column A
2. vlookup function in columns b:g should bring up product information, then focus goes to column i
3. after user enters data into column i, focus should go to next row, first column (this does work from above)
4. if step 2 comes up as N/A then i want focus to go to column b for user input.
5. after user inputs in column b then to column i and step 3.


This is giving me a headache. I'm good with excel, but not vb.

Thanks in advance!
 

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.

Forum statistics

Threads
1,224,312
Messages
6,177,812
Members
452,806
Latest member
Workerl3ee

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