coliervile
Well-known Member
- Joined
- May 19, 2006
- Messages
- 724
The following code is suppose to unload data from a VBA form into the first empty cell in column A and in columns A, B, E, H, K, and N...but it is not doing that. I'm racking my brain here and can't fiure out why...every have one of these days???
Thanks for looking and your help-
Charlie
Here is the header:
Last Row:
Form Coding:
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Funds")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 0).Row
'check for a date
If Trim(Me.txtDate.Value) = "" Then
Me.txtDate.SetFocus
MsgBox "Please enter date"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 0).Value = Me.txtDate.Value
ws.Cells(iRow, 1).Value = Me.txtG.Value
ws.Cells(iRow, 4).Value = Me.txtF.Value
ws.Cells(iRow, 7).Value = Me.txtC.Value
ws.Cells(iRow, 10).Value = Me.txtS.Value
ws.Cells(iRow, 13).Value = Me.txtI.Value
'clear the data
Me.txtDate.Value = ""
Me.txtG.Value = ""
Me.txtF.Value = ""
Me.txtC.Value = ""
Me.txtS.Value = ""
Me.txtI.Value = ""
Me.txtDate.SetFocus
End Sub
Thanks for looking and your help-
Charlie
Here is the header:
Excel Workbook | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | |||
1 | Date | G | $ Change | % Change | F | $ Change | % Change | C | $ Change | % Change | S | $ Change | % Change | I | $ Change | % Change | Best | Worst | ||
Funds |
Last Row:
Excel Workbook | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | |||
4095 | 26-Apr-11 | 13.6146 | 0.0011 | 0.0001 | 14.4436 | 0.0303 | 0.0021 | 16.3808 | 0.1457 | 0.0090 | 23.3091 | 0.2180 | 0.0094 | 21.4651 | 0.1071 | 0.0050 | S | G | ||
4096 | 27-Apr-11 | 13.6158 | 0.0012 | 0.0001 | 14.4218 | (0.0218) | (0.0015) | 16.4861 | 0.1053 | 0.0064 | 23.4610 | 0.1519 | 0.0065 | 21.7507 | 0.2856 | 0.0133 | I | F | ||
4097 | 28-Apr-11 | 13.6169 | 0.0011 | 0.0001 | 14.4597 | 0.0379 | 0.0026 | 16.5459 | 0.0598 | 0.0036 | 23.5252 | 0.0642 | 0.0027 | 21.8792 | 0.1285 | 0.0059 | I | G | ||
4098 | 29-Apr-11 | 13.6192 | 0.0023 | 0.0002 | 14.4751 | 0.0154 | 0.0011 | 16.5841 | 0.0382 | 0.0023 | 23.6175 | 0.0923 | 0.0039 | 21.9484 | 0.0692 | 0.0032 | S | G | ||
4099 | * | * | (13.6192) | (1.0000) | * | (14.4751) | (1.0000) | * | (16.5841) | (1.0000) | * | (23.6175) | (1.0000) | * | (21.9484) | (1.0000) | G | G | ||
Funds |
Form Coding:
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Funds")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(0, 0).Row
'check for a date
If Trim(Me.txtDate.Value) = "" Then
Me.txtDate.SetFocus
MsgBox "Please enter date"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 0).Value = Me.txtDate.Value
ws.Cells(iRow, 1).Value = Me.txtG.Value
ws.Cells(iRow, 4).Value = Me.txtF.Value
ws.Cells(iRow, 7).Value = Me.txtC.Value
ws.Cells(iRow, 10).Value = Me.txtS.Value
ws.Cells(iRow, 13).Value = Me.txtI.Value
'clear the data
Me.txtDate.Value = ""
Me.txtG.Value = ""
Me.txtF.Value = ""
Me.txtC.Value = ""
Me.txtS.Value = ""
Me.txtI.Value = ""
Me.txtDate.SetFocus
End Sub