Forum Discussion
Macro Button of products that adds the selected product into order list
- Jan 24, 2021
Let's say you want to enter Wash Plate 1 or Wash Plate 2 in H16 and down.
Sub WashPlate1()
Dim r As Row
r = Range("H82").End(xlUp).Row
If r >= 80 Then
MsgBox "Geen ruimte meer!", vbCritical
Else
Range("H" & r + 1).Value = "Wash Plate 1"
End If
End Sub
Sub WashPlate2()
Dim r As Row
r = Range("H82").End(xlUp).Row
If r >= 80 Then
MsgBox "Geen ruimte meer!", vbCritical
Else
Range("H" & r + 1).Value = "Wash Plate 2"
End If
End Sub- MdjongJan 24, 2021Copper Contributor
HansVogelaar
I get the following error: Compile error: User-defined data type not definedAnd it will mark the following yellow : Dim r as Row.
If i try a different data type, like Range it will give: objectvariable or blockvariable with not defined.
So i tried the following:
Sub WashPlate1()
Dim r As Range
Set r = Range("H80").End(xlUp)
If r >= 80 Then
MsgBox "Geen ruimte meer!", vbCritical
Else
Range("H" & r + 1).Value = "Wash Plate 1"
End If
End SubWith the code above i get the "Geen ruimte meer" msg. Only nothing will be added, and there is still place left.
if i change the code to:
Sub WashPlate1()
Dim r As Range
Set r = Range("U80").End(xlUp)
If r >= 80 Then
MsgBox "Geen ruimte meer!", vbCritical
Else
Range("U" & r + 1).Value = "Wash Plate 1"
End If
End SubThe code works, probably because column U is completely empty:
But the question now is, How can i make sure this happens within "H". And also if i click again, i will get the msg "Geen ruimte" again and i can't seem to get wash plate 1 in the cell beneath "U1".
Like this:
Wash plate 1
Wash plate 1Could you help me further?
- HansVogelaarJan 24, 2021MVP
- MdjongJan 24, 2021Copper ContributorIt works!!
Thank you very much!