Sandra Smith
asked on
Add data to the end of a range
I multiple range that, thorugh forms and VBA, i need to add data to. The procedure does add a blank row (shitfs down one line for the insert), but when I use the Cells function,it throws an error. I do not know why. I get run time error of 424, Object required.
Private Sub InsertData()
'First need to insert a row below range, then add new data and
'finally call the range reset procedure
intRowEnd = fntRangeStartEndsRows("End", "ss_WAL") + 1
ThisWorkbook.Worksheets("Datasource").Range("L" & intRowEnd & ":" & "P" & intRowEnd).Select
ThisWorkbook.Worksheets("Datasource").Range("L" & intRowEnd & ":" & "P" & intRowEnd).Select
Selection.Insert Shift:=xlDown
With ThisWorkbook.Worksheets("Datasource").Range("ss_WAL").Rows.Count + 1
.Cells(0, 1).Value = Me.txtWAL.Value
.Cells(1, 2).Value = Me.txtLookupClient.Value
.Cells(2, 3).Value = Me.txtLookupLehman.Value
.Cells(3, 4).Value = Me.txtColumnNumber.Value
.cell(3, 5).Value = Me.txtRangeName.Value
End With
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
actually, I have solved it. attached is the code and it works.
Private Sub InsertData()
Dim intCount As Integer
'First need to insert a row below range, then add new data and
'finally call the range reset procedure
intRowEnd = fntRangeStartEndsRows("End", "ss_WAL") + 1
ThisWorkbook.Worksheets("Datasource").Range("L" & intRowEnd & ":" & "P" & intRowEnd).Select
Selection.Insert Shift:=xlDown
intCount = ThisWorkbook.Worksheets("Datasource").Range("ss_WAL").Rows.Count + 1
With ThisWorkbook.Worksheets("Datasource").Range("ss_WAL")
.Cells(intCount, 1).Value = Me.txtWAL.Value
.Cells(intCount, 2).Value = Me.txtLookupClient.Value
.Cells(intCount, 3).Value = Me.txtLookupLehman.Value
.Cells(intCount, 4).Value = Me.txtColumnNumber.Value
.Cells(intCount, 5).Value = Me.txtRangeName.Value
End With
End Sub
ASKER
This was the first step toward success so I did need to change that.
thx...Glad you were able to work through it :)
ASKER