Hey guys, first post here but I have been a follower/reader for quite a while.
I currently have a userform that enters into whatever table you double clicked on (Userform opens on double click). It will populate that current table properly no issues. I want it to populate the same information into a 2nd table to collect data from all the individual tables in one. So in the end I need the Userform to still fill in the table double clicked on but also fill in the same information on another table.
I hope I explained this well enough to get the drift.
Here is the code I have for the one (1) table:
Private Sub buylong_Click()
'General Variables
Dim numRows As Long
numRows = Range(Selection.ListObject.Name).Rows.Count
Dim firstRow As Long
firstRow = Range(Selection.ListObject.Name).Row
Dim tableName As String
tableName = Selection.ListObject.Name
Set tbl = ActiveSheet.ListObjects(tableName)
Dim x As Long
'-----------------------------------------------------------------------------------------------------------------
Dim currentRow As Long
currentRow = firstRow - 1
For x = 1 To tbl.Range.Rows.Count
If WorksheetFunction.CountA(tbl.Range.Rows(x)) = 0 Then
'Add the values to the current RECAP table
Worksheets("Recap").Cells(currentRow, 2).Value = Now
Worksheets("Recap").Cells(currentRow, 5).Value = "LONG"
Worksheets("Recap").Cells(currentRow, 3).Value = Ticker.Value
Worksheets("Recap").Cells(currentRow, 4).Value = Qty.Value
Worksheets("Recap").Cells(currentRow, 6).Value = entryprice.Value
Worksheets("Recap").Cells(currentRow, 7).Value = exitprice.Value
'Change Price of trading fees here!!!
Worksheets("Recap").Cells(currentRow, 8).Value = 4.95 * 2
Application.ScreenUpdating = True
Unload Me
Exit Sub
End If
currentRow = currentRow + 1
Next x
Dim endRow As Long
endRow = firstRow + numRows
'Find last row of table and adds a new row + resizes the table
Cells(endRow, 1).EntireRow.Insert
With tbl.Range
tbl.Resize .Resize(.CurrentRegion.Rows.Count)
End With
'Add the values to the current RECAP table
Worksheets("Recap").Cells(endRow, 2).Value = Now
Worksheets("Recap").Cells(endRow, 5).Value = "LONG"
Worksheets("Recap").Cells(endRow, 3).Value = Ticker.Value
Worksheets("Recap").Cells(endRow, 4).Value = Qty.Value
Worksheets("Recap").Cells(endRow, 6).Value = entryprice.Value
Worksheets("Recap").Cells(endRow, 7).Value = exitprice.Value
'Change Price of trading fees here!!!
Worksheets("Recap").Cells(endRow, 8).Value = 4.95 * 2
Application.ScreenUpdating = True
Sort
Unload Me
End Sub
I currently have a userform that enters into whatever table you double clicked on (Userform opens on double click). It will populate that current table properly no issues. I want it to populate the same information into a 2nd table to collect data from all the individual tables in one. So in the end I need the Userform to still fill in the table double clicked on but also fill in the same information on another table.
I hope I explained this well enough to get the drift.
Here is the code I have for the one (1) table:
Private Sub buylong_Click()
'General Variables
Dim numRows As Long
numRows = Range(Selection.ListObject.Name).Rows.Count
Dim firstRow As Long
firstRow = Range(Selection.ListObject.Name).Row
Dim tableName As String
tableName = Selection.ListObject.Name
Set tbl = ActiveSheet.ListObjects(tableName)
Dim x As Long
'-----------------------------------------------------------------------------------------------------------------
Dim currentRow As Long
currentRow = firstRow - 1
For x = 1 To tbl.Range.Rows.Count
If WorksheetFunction.CountA(tbl.Range.Rows(x)) = 0 Then
'Add the values to the current RECAP table
Worksheets("Recap").Cells(currentRow, 2).Value = Now
Worksheets("Recap").Cells(currentRow, 5).Value = "LONG"
Worksheets("Recap").Cells(currentRow, 3).Value = Ticker.Value
Worksheets("Recap").Cells(currentRow, 4).Value = Qty.Value
Worksheets("Recap").Cells(currentRow, 6).Value = entryprice.Value
Worksheets("Recap").Cells(currentRow, 7).Value = exitprice.Value
'Change Price of trading fees here!!!
Worksheets("Recap").Cells(currentRow, 8).Value = 4.95 * 2
Application.ScreenUpdating = True
Unload Me
Exit Sub
End If
currentRow = currentRow + 1
Next x
Dim endRow As Long
endRow = firstRow + numRows
'Find last row of table and adds a new row + resizes the table
Cells(endRow, 1).EntireRow.Insert
With tbl.Range
tbl.Resize .Resize(.CurrentRegion.Rows.Count)
End With
'Add the values to the current RECAP table
Worksheets("Recap").Cells(endRow, 2).Value = Now
Worksheets("Recap").Cells(endRow, 5).Value = "LONG"
Worksheets("Recap").Cells(endRow, 3).Value = Ticker.Value
Worksheets("Recap").Cells(endRow, 4).Value = Qty.Value
Worksheets("Recap").Cells(endRow, 6).Value = entryprice.Value
Worksheets("Recap").Cells(endRow, 7).Value = exitprice.Value
'Change Price of trading fees here!!!
Worksheets("Recap").Cells(endRow, 8).Value = 4.95 * 2
Application.ScreenUpdating = True
Sort
Unload Me
End Sub