Hi
I am trying to create a form where the user will be able to move machines from building to building depending on the building, floor and zone they choose. It will also look at the month to determine from when the move needs to happen. It will then reference one of the three tables that holds the serial numbers of all the machines and determine, depending on which table they are in, how many rows to cut and paste.
Firstly, am I doing this the correct way or is there a much simpler solution to my problems
Secondly, this is the code I have so far, I am only building a small prototype to prove to my manager it works and as such it only had 2 buildings and 3 months but obviously the full version will have all the buildings and months
[pre]
[/pre]
Thanks
Rob
I am trying to create a form where the user will be able to move machines from building to building depending on the building, floor and zone they choose. It will also look at the month to determine from when the move needs to happen. It will then reference one of the three tables that holds the serial numbers of all the machines and determine, depending on which table they are in, how many rows to cut and paste.
Firstly, am I doing this the correct way or is there a much simpler solution to my problems
Secondly, this is the code I have so far, I am only building a small prototype to prove to my manager it works and as such it only had 2 buildings and 3 months but obviously the full version will have all the buildings and months
[pre]
Code:
Public Sub UserForm_Initialize()
'Populate building combo box.
Dim rngBuliding As Range
Dim ws As Worksheet
Set ws = Worksheets("LookUpLists")
For Each rngBuilding In ws.Range("Building")
Me.CBBuilding.AddItem rngBuilding.Value
Next rngBuilding
'Populate floor combo box
Dim rngFloor As Range
Set ws = Worksheets("LookUpLists")
For Each rngFloor In ws.Range("Floor")
Me.CBFloor.AddItem rngFloor.Value
Next rngFloor
'Populate zone combo box
Dim rngZone As Range
Set ws = Worksheets("LookUpLists")
For Each rngZone In ws.Range("Zone")
Me.CBZone.AddItem rngZone.Value
Next rngZone
End Sub
Private Sub Save_Click()
Dim TBSerialNo As Integer
Dim CBBuilding As String
Dim TBMonth As String
Dim CBFloor As String
Dim CBZone As String
Dim From_Book As Workbook, To_Book As Workbook
Dim From_Sheet As Worksheet, To_Sheet As Worksheet
Dim sheet_name As String
Dim ws As Worksheet
Sheets("LookUpLists").Visible = True
If TBSerialNo = Index(three_meter_reads) Then
If TBSerialNo = Range("F3:F74") Then
If TBMonth = ("Jan") Then
Sheets("Jan").Visible = True
ElseIf TBMonth = ("Feb") Then
Sheets("Feb").Visible = True
ElseIf TBMonth = ("Mar") Then
Sheets("March").Visible = True
Else: i = MsgBox("Month not found", vbOKOnly)
End If
End If
End Sub
Thanks
Rob