Finding first empty cell in selected area depending on weight and product

apoliboli

New Member
Joined
Jun 23, 2017
Messages
7
Hi. I have written the code below searching in google. I am very pleased with myself since i cant code. Now i am stuck and i need help.
As you can see in the form i want to register different products that has different weight. Depending on that i want the code to find the right cell and to register (as text) that in the cell.
ZAA==

Here is the code : Option Explicit


Private Sub Delete_Click()

End Sub



Private Sub GWTextBox_Enter()
Me.Label2 = 2
End Sub

Private Sub Nr0_Click()
If Me.Label2 = 1 Then
Me.PallekarmerTextBox = Me.PallekarmerTextBox & "0"
ElseIf Me.Label2 = 2 Then
Me.GWTextBox = Me.GWTextBox & "0"
Else: Me.StkTextBox = Me.StkTextBox & "0"
End If
End Sub

Private Sub Nr1_Click()
If Me.Label2 = 1 Then
Me.PallekarmerTextBox = Me.PallekarmerTextBox & "1"
ElseIf Me.Label2 = 2 Then
Me.GWTextBox = Me.GWTextBox & "1"
Else: Me.StkTextBox = Me.StkTextBox & "1"
End If

End Sub

Private Sub Nr2_Click()
If Me.Label2 = 1 Then
Me.PallekarmerTextBox = Me.PallekarmerTextBox & "2"
ElseIf Me.Label2 = 2 Then
Me.GWTextBox = Me.GWTextBox & "2"
Else: Me.StkTextBox = Me.StkTextBox & "2"
End If
End Sub

Private Sub Nr3_Click()
If Me.Label2 = 1 Then
Me.PallekarmerTextBox = Me.PallekarmerTextBox & "3"
ElseIf Me.Label2 = 2 Then
Me.GWTextBox = Me.GWTextBox & "3"
Else: Me.StkTextBox = Me.StkTextBox & "3"
End If
End Sub

Private Sub Nr4_Click()
If Me.Label2 = 1 Then
Me.PallekarmerTextBox = Me.PallekarmerTextBox & "4"
ElseIf Me.Label2 = 2 Then
Me.GWTextBox = Me.GWTextBox & "4"
Else: Me.StkTextBox = Me.StkTextBox & "4"
End If
End Sub

Private Sub Nr5_Click()
If Me.Label2 = 1 Then
Me.PallekarmerTextBox = Me.PallekarmerTextBox & "5"
ElseIf Me.Label2 = 2 Then
Me.GWTextBox = Me.GWTextBox & "5"
Else: Me.StkTextBox = Me.StkTextBox & "5"
End If
End Sub

Private Sub Nr6_Click()
If Me.Label2 = 1 Then
Me.PallekarmerTextBox = Me.PallekarmerTextBox & "6"
ElseIf Me.Label2 = 2 Then
Me.GWTextBox = Me.GWTextBox & "6"
Else: Me.StkTextBox = Me.StkTextBox & "6"
End If
End Sub

Private Sub Nr7_Click()
If Me.Label2 = 1 Then
Me.PallekarmerTextBox = Me.PallekarmerTextBox & "7"
ElseIf Me.Label2 = 2 Then
Me.GWTextBox = Me.GWTextBox & "7"
Else: Me.StkTextBox = Me.StkTextBox & "7"
End If
End Sub

Private Sub Nr8_Click()
If Me.Label2 = 1 Then
Me.PallekarmerTextBox = Me.PallekarmerTextBox & "8"
ElseIf Me.Label2 = 2 Then
Me.GWTextBox = Me.GWTextBox & "8"
Else: Me.StkTextBox = Me.StkTextBox & "8"
End If
End Sub

Private Sub Nr9_Click()
If Me.Label2 = 1 Then
Me.PallekarmerTextBox = Me.PallekarmerTextBox & "9"
ElseIf Me.Label2 = 2 Then
Me.GWTextBox = Me.GWTextBox & "9"
Else: Me.StkTextBox = Me.StkTextBox & "9"
End If
End Sub

Private Sub NrDel_Click()
If Me.Label2 = 1 Then
Me.PallekarmerTextBox = ""
ElseIf Me.Label2 = 2 Then
Me.GWTextBox = ""
Else: Me.StkTextBox = ""
End If
End Sub

Private Sub PallekarmerTextBox_Enter()
Me.Label2 = 1
End Sub

Private Sub PallOptionButton_Click()

End Sub

Private Sub SpinButton1_Change()

End Sub


Private Sub StkTextBox_Enter()
Me.Label2 = 3
End Sub

Private Sub VareComboBox_Change()

End Sub

Private Sub ClearButton_Click()

Call UserForm_Initialize

End Sub

Private Sub AvsenderComboBox_Change()

End Sub

Private Sub PallekarmerSpinButton_Change()

PallekarmerTextBox.Text = PallekarmerSpinButton.Value

End Sub

Private Sub OKButton_Click()

Me.Hide

Dim emptyRow As Long

'Make Sheet1 active
Sheet1.Activate

'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1


'Transfer information
Cells(emptyRow, 1).Value = DatoTextBox.Value
Cells(emptyRow, 2).Value = VareComboBox.Value
Cells(emptyRow, 3).Value = AvsenderComboBox.Value
Cells(emptyRow, 5).Value = PallekarmerTextBox.Value
Cells(emptyRow, 6).Value = GWTextBox.Value

If BurOptionButton.Value = True Then
Cells(emptyRow, 4).Value = "Bur"
Else
Cells(emptyRow, 4).Value = "Pall"
End If
Call UserForm_Initialize
End Sub




Private Sub UserForm_Initialize()

DatoTextBox.Value = Format(Date, "dd/mm/yyyy")

'Empty VareComboBox
VareComboBox.Clear

'Fill VareComboBox
With VareComboBox
.AddItem "PC"
.AddItem "Servere"
.AddItem "PC-Servere"
End With

'Empty AvsenderComboBox
AvsenderComboBox.Clear

'Fill AvsenderComboBox
With AvsenderComboBox
.AddItem "ATEA"
.AddItem "AD"
.AddItem "STENA"
End With

'Set Pall as default
PallOptionButton.Value = True
Me.GWTextBox.Text = ""
Me.PallekarmerTextBox = ""
End Sub

So, if the item is a "PC" that weight >500kg i want it to find the first empty cell C5-G5
If the item is a "PC" that weight <499kg or <400kg i want it to find the first empty cell C4-G4
If the item is a "PC" that weight <399kg or <300kg i want it to find the first empty cell C3-G3
If the item is a "PC" that weight <299kg or <200kg i want it to find the first empty cell C2-G2

If the item is a "Server" that weight <499kg or <400kg i want it to find the first empty cell H4-L4
If the item is a "Server" that weight <399kg or <300kg i want it to find the first empty cell H3-L3
If the item is a "Server" that weight <299kg or <200kg i want it to find the first empty cell H2-L2

etc etc

and last, if its possible to copy the text (Pc or Server, and the weight) in the selected cell

Any help is appreciated
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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