Need VBA macro that asks for data validation from a cell, then moves to next cell

TsarMarkI

New Member
Joined
Aug 14, 2019
Messages
20
Good Morning, all,

Hoping to get some help with a macro I'm trying to create. In essence, I'm trying to write VBA for excel to look at a value in a cell, take an inputted value from the user, and validate that the inputted value matches the value in the cell it's looking at. If the value does match, excel would then move to the next cell in the column, and perform the same function again. I'm also trying to do this while providing text and input boxes to the user.

Ideal state, it would look like this:

Macro prompts user with infobox for value in A2
C2= 40
User Input (value placed into D2) = 40
Value for C2 and D2 match
Excel moves to A3
C3= 40
User Input (value placed into D3)= 40
Value for C3 and D3 match
Excel moves to A4
C4= 40
User Input (value placed into D4) = 30
Value for C4 and D4 do not match
Excel requires user to input D4 again. If D4 is still incorrect, Excel moves to A5
Macro stops when it arrives at blank cell in column A

Here is some of the code I've been working on to accomplish this- where I am stuck is how to get excel to move to the next cell in column A, and how to make it check again when a non-matching value is entered before moving to the next cell in column A.

Sub Entry()
'
Dim myValue As Variant


Range("A2").Select


MsgBox "Please move to bin " & ActiveCell.Value
myValue = InputBox("Please enter the total quantity in " & ActiveCell.Value)
Range("D2").Value = myValue
If myValue = Range("C2").Value Then
ActiveCell.Offset(1, 0).Select
End If
'
End Sub

Any help would be greatly appreciated!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi & welcome to MrExcel.
How about
Code:
Sub TsarMarkI()
   Dim Cl As Range
   Dim Res As Variant
   Dim i As Long
   
   For Each Cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
      For i = 1 To 2
         Res = InputBox("Please enter the total quantity in " & Cl.Value)
         If Res = "" Then Exit Sub
         Cl.Offset(, 3).Value = val(Res)
         If val(Res) = Cl.Offset(, 2).Value Then Exit For
      Next i
   Next Cl
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
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