dellehurley
Board Regular
- Joined
- Sep 26, 2009
- Messages
- 171
- Office Version
- 365
- Platform
- Windows
Hello,
I am really hoping someone came help me. I have been trying to teach my self VBA using YouTube etc as my teacher. I have working on this Data Form, I am getting there but I having one issue. I have tried heaps of things and this is the closest I have come to it working.
I have set up a user form. My issue is the record in green should be one line and the record in yellow another. #Value should be replaced with the File name.
I have gone around in circle but this trying to make it work the code I have now is.....
Dim msgValue As VbMsgBoxResult
Dim sh4 As Worksheet
Dim sh2 As Worksheet
Dim iRow As Long
iRow = [Counta(Database!A:A)] ' identifying the last row
Set sh4 = ThisWorkbook.Sheets("File Name Sheet")
Set sh2 = ThisWorkbook.Sheets("Database")
With sh4
.Range("J12").Value = Me.cmbFileNo.Value
.Range("K12").Value = Me.cmbType.Value
.Range("L12").Value = Me.cmbEvent.Value
.Range("M12").Value = Me.cmbExt.Value
If FrmForm.txtRowNumber.Value = "" Then
iRow = [Counta(Database!A:A)] + 1
Else
iRow = FrmForm.txtRowNumber.Value
End If
With sh2
.Cells(iRow, 1) = sh4.Range("I12").Value
If msgValue = vbNo Then Exit Sub
Call Submit
Call Reset
End With
End With
(I realise the last "end with" shouldn't be there but it does not work at all without it.) Any advise is appreciated. Dannielle
I am really hoping someone came help me. I have been trying to teach my self VBA using YouTube etc as my teacher. I have working on this Data Form, I am getting there but I having one issue. I have tried heaps of things and this is the closest I have come to it working.
I have set up a user form. My issue is the record in green should be one line and the record in yellow another. #Value should be replaced with the File name.
I have gone around in circle but this trying to make it work the code I have now is.....
Dim msgValue As VbMsgBoxResult
Dim sh4 As Worksheet
Dim sh2 As Worksheet
Dim iRow As Long
iRow = [Counta(Database!A:A)] ' identifying the last row
Set sh4 = ThisWorkbook.Sheets("File Name Sheet")
Set sh2 = ThisWorkbook.Sheets("Database")
With sh4
.Range("J12").Value = Me.cmbFileNo.Value
.Range("K12").Value = Me.cmbType.Value
.Range("L12").Value = Me.cmbEvent.Value
.Range("M12").Value = Me.cmbExt.Value
If FrmForm.txtRowNumber.Value = "" Then
iRow = [Counta(Database!A:A)] + 1
Else
iRow = FrmForm.txtRowNumber.Value
End If
With sh2
.Cells(iRow, 1) = sh4.Range("I12").Value
If msgValue = vbNo Then Exit Sub
Call Submit
Call Reset
End With
End With
(I realise the last "end with" shouldn't be there but it does not work at all without it.) Any advise is appreciated. Dannielle