phatphil3c
New Member
- Joined
- Jan 13, 2023
- Messages
- 4
- Office Version
- 2013
- Platform
- Windows
Hello!
Very new to this so I'm sorry in advance! I was able to create a vba form with text fields, dropdown lists, command buttons and radio buttons (for maintenance requests). I am able to successfully transfer this data to another spreadsheet with date and time stamps and also generate jobs numbers (searches for the largest number in column A as the info gets sorted, then adds the next consecutive number). This number is then used to generate the job number in column B (example RMR-0009).
The code below is what is used on my 1st tab. However, there are 5 tabs total (all vba forms: maint request, work done by maint, quality dept verification, etc) that transfer information to 1 spreadsheet. I use similar code on the other tabs to add new line of data to the spreadsheet (all I've been able to figure out). However, no one at the job including me wants to read several rows of info just for 1 job number.
Can anyone advise how to search for the desired job number in column B, use that information to identify the row it came from, and then add more data down the line on that specific row? You can see below for this maint request that columns N through AB will be recorded on the spreadsheet as N/A (which is necessary documentation in my business, can't just leave them blank). I would like to replace those N/A's with the updated information. Each vba form has a dropdown list to choose the job number (called cmbjobnumber). Whatever job number the operator chooses is the value that needs to be identified in column B. Again sorry I am new and hope I provided good enough info (and also not too much). Thanks for any help that can be provided!!
Private Sub cmdSaveClose_Click()
Application.ScreenUpdating = False
Dim irow As Long
Dim Rng As Range
Dim ws As Worksheet
Set ws = Worksheets("Maint Request Data")
irow = Sheets("Maint Request Data").Range("A1048576").End(xlUp).Row + 1
If ValidateForm = True Then
With ThisWorkbook.Sheets("Maint Request Data")
.Range("A" & irow).Value = Application.WorksheetFunction.Large(ws.Range("A1:A1048576"), 1) + 1
.Range("B" & irow).Value = "RMR-" & Format(.Range("A" & irow).Value, "0000")
.Range("C" & irow).Value = txtReportedBy.Value
.Range("D" & irow).Value = Format(Now(), "MM/DD/YYYY")
.Range("E" & irow).Value = Format(Now(), "Long Time")
.Range("F" & irow).Value = cmbEquipmentLocation.Text
If optMoldingEquipment.Value Then .Range("G" & irow).Value = "Molding Equipment"
If optLeakFlowTester.Value Then .Range("G" & irow).Value = "Leak/Flow Tester"
If optAllOtherEquipment.Value Then .Range("G" & irow).Value = "All Other Equipment"
.Range("H" & irow).Value = txtEquipmentID.Value
If txtLoadBarID.Value = "" Then .Range("I" & irow).Value = "N/A" Else .Range("I" & irow).Value = txtLoadBarID.Value
If txtCavityID.Value = "" Then .Range("J" & irow).Value = "N/A" Else .Range("J" & irow).Value = txtCavityID.Value
.Range("K" & irow).Value = IIf(optEquipmentStatusYes.Value = True, "In-Use", "Not In-Use")
If txtPartNumber.Value = "" Then .Range("L" & irow).Value = "N/A" Else .Range("L" & irow).Value = txtPartNumber.Value
If txtLotNumber.Value = "" Then .Range("M" & irow).Value = "N/A" Else .Range("M" & irow).Value = txtLotNumber.Value
.Range("N" & irow).Value = txtProblemDescription.Value
.Range("O" & irow).Value = "N/A"
.Range("P" & irow).Value = "N/A"
.Range("Q" & irow).Value = "N/A"
.Range("R" & irow).Value = "N/A"
.Range("S" & irow).Value = "N/A"
.Range("T" & irow).Value = "N/A"
.Range("U" & irow).Value = "N/A"
.Range("V" & irow).Value = "N/A"
.Range("W" & irow).Value = "N/A"
.Range("X" & irow).Value = "N/A"
.Range("Y" & irow).Value = "N/A"
.Range("Z" & irow).Value = "N/A"
.Range("AA" & irow).Value = "N/A"
.Range("AB" & irow).Value = "N/A"
End With
Call Reset
Else
Application.ScreenUpdating = True
Exit Sub
End If
Application.ScreenUpdating = True
End Sub
Very new to this so I'm sorry in advance! I was able to create a vba form with text fields, dropdown lists, command buttons and radio buttons (for maintenance requests). I am able to successfully transfer this data to another spreadsheet with date and time stamps and also generate jobs numbers (searches for the largest number in column A as the info gets sorted, then adds the next consecutive number). This number is then used to generate the job number in column B (example RMR-0009).
The code below is what is used on my 1st tab. However, there are 5 tabs total (all vba forms: maint request, work done by maint, quality dept verification, etc) that transfer information to 1 spreadsheet. I use similar code on the other tabs to add new line of data to the spreadsheet (all I've been able to figure out). However, no one at the job including me wants to read several rows of info just for 1 job number.
Can anyone advise how to search for the desired job number in column B, use that information to identify the row it came from, and then add more data down the line on that specific row? You can see below for this maint request that columns N through AB will be recorded on the spreadsheet as N/A (which is necessary documentation in my business, can't just leave them blank). I would like to replace those N/A's with the updated information. Each vba form has a dropdown list to choose the job number (called cmbjobnumber). Whatever job number the operator chooses is the value that needs to be identified in column B. Again sorry I am new and hope I provided good enough info (and also not too much). Thanks for any help that can be provided!!
Private Sub cmdSaveClose_Click()
Application.ScreenUpdating = False
Dim irow As Long
Dim Rng As Range
Dim ws As Worksheet
Set ws = Worksheets("Maint Request Data")
irow = Sheets("Maint Request Data").Range("A1048576").End(xlUp).Row + 1
If ValidateForm = True Then
With ThisWorkbook.Sheets("Maint Request Data")
.Range("A" & irow).Value = Application.WorksheetFunction.Large(ws.Range("A1:A1048576"), 1) + 1
.Range("B" & irow).Value = "RMR-" & Format(.Range("A" & irow).Value, "0000")
.Range("C" & irow).Value = txtReportedBy.Value
.Range("D" & irow).Value = Format(Now(), "MM/DD/YYYY")
.Range("E" & irow).Value = Format(Now(), "Long Time")
.Range("F" & irow).Value = cmbEquipmentLocation.Text
If optMoldingEquipment.Value Then .Range("G" & irow).Value = "Molding Equipment"
If optLeakFlowTester.Value Then .Range("G" & irow).Value = "Leak/Flow Tester"
If optAllOtherEquipment.Value Then .Range("G" & irow).Value = "All Other Equipment"
.Range("H" & irow).Value = txtEquipmentID.Value
If txtLoadBarID.Value = "" Then .Range("I" & irow).Value = "N/A" Else .Range("I" & irow).Value = txtLoadBarID.Value
If txtCavityID.Value = "" Then .Range("J" & irow).Value = "N/A" Else .Range("J" & irow).Value = txtCavityID.Value
.Range("K" & irow).Value = IIf(optEquipmentStatusYes.Value = True, "In-Use", "Not In-Use")
If txtPartNumber.Value = "" Then .Range("L" & irow).Value = "N/A" Else .Range("L" & irow).Value = txtPartNumber.Value
If txtLotNumber.Value = "" Then .Range("M" & irow).Value = "N/A" Else .Range("M" & irow).Value = txtLotNumber.Value
.Range("N" & irow).Value = txtProblemDescription.Value
.Range("O" & irow).Value = "N/A"
.Range("P" & irow).Value = "N/A"
.Range("Q" & irow).Value = "N/A"
.Range("R" & irow).Value = "N/A"
.Range("S" & irow).Value = "N/A"
.Range("T" & irow).Value = "N/A"
.Range("U" & irow).Value = "N/A"
.Range("V" & irow).Value = "N/A"
.Range("W" & irow).Value = "N/A"
.Range("X" & irow).Value = "N/A"
.Range("Y" & irow).Value = "N/A"
.Range("Z" & irow).Value = "N/A"
.Range("AA" & irow).Value = "N/A"
.Range("AB" & irow).Value = "N/A"
End With
Call Reset
Else
Application.ScreenUpdating = True
Exit Sub
End If
Application.ScreenUpdating = True
End Sub