Basically in my excel workbook, I have multiple worksheets with inventory data except for the first worksheet, which is meant for inputting values specifically the dates of the month, and what I want is for the code to identify the input dates from the inputbox to find column headings in those respective inventory data, and from there input the value into the desired cell in the correct row and column. Or in simple terms, is VBA able to find columns from another worksheet based on an input? Is that possible?
Here is my initial attempt for the code, but unfortunately I got stuck and did not know how to continue:
Private Sub Label1_Click()
'input variable declaration
Dim inputValue As Variant
Dim inputValue2 As Variant
Dim lowerLimit As Long
Dim upperLimit As Long
Dim response As String
'date range of the month
lowerLimit = 1
upperLimit = 31
'input box getting the user's date of choice
inputValue = InputBox("Please enter a Date")
If Not IsNumeric(inputValue) Then
MsgBox "Dates can only be numeric!"
Exit Sub
Else
End If
If inputValue < lowerLimit Or inputValue > upperLimit Then
MsgBox "Dates cannot be below 1 or above 31!"
Exit Sub
End If
If IsNumeric(inputValue) Then
'2nd input box getting the user's quantity used of choice
inputValue2 = InputBox("Enter quantity used.")
If Not IsNumeric(inputValue2) Then
MsgBox "Quantity added can only be numeric!"
Exit Sub
End If
Else
'Part where code identifies which column to input value
Set SearchRange = Worksheets("Sheet2").Range("D2:AH2")
FindWhat = inputValue
If FindWhat(inputValue) <> "" Then
End If
End Sub
3rd Edit: I tried my best for a pictorial representation, hopefully it is slightly easier to understand what I am trying to achieve. enter image description here