kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
Hello,
I came up with this code and I am stacked here as to what I wanna achieve.
I need 8 variables; what I have here is just two of those. They are assigned by the inputbox, then after that send them to my worksheet by breaking the input into two where the comma appears in the user input. The first part of the input will be a string data while the second part is number value.
So from what I have here as an example, if I enter say “apple,3” as the input for MyVar1, then cell A1 takes “apple” and cell B1 takes “3”.
Then when I enter say “Mango,34” as the input for MyVar2, then cell C1 takes “Mango” and cell D1 takes “34”, etc
I want someone help pull me out
Blank inputs are accepted but if not blank then all two criteria “label, number” must be there.
I came up with this code and I am stacked here as to what I wanna achieve.
I need 8 variables; what I have here is just two of those. They are assigned by the inputbox, then after that send them to my worksheet by breaking the input into two where the comma appears in the user input. The first part of the input will be a string data while the second part is number value.
So from what I have here as an example, if I enter say “apple,3” as the input for MyVar1, then cell A1 takes “apple” and cell B1 takes “3”.
Then when I enter say “Mango,34” as the input for MyVar2, then cell C1 takes “Mango” and cell D1 takes “34”, etc
I want someone help pull me out
Blank inputs are accepted but if not blank then all two criteria “label, number” must be there.
Code:
Sub InputThings()
Dim MyVar1, MyVar2
MyVar1 = InputBox("Enter details like:'Label 1,Number'")
MyVar2 = InputBox("Enter details like:'Label 2,Number'")
Sheet2.Range("A1").Value = MyVar1 'take the part before the comma the comma
Sheet2.Range("B1").Value = MyVar1 'take the part after the comma
Sheet2.Range("C1").Value = MyVar2 'take the part before the comma the comma
Sheet2.Range("D1").Value = MyVar2 'take the part after the comma
End Sub