Solved

Add data to the end of a range

Posted on 2011-03-09
5
205 Views
Last Modified: 2012-06-21
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

Open in new window

0
Comment
Question by:ssmith94015
  • 3
  • 2
5 Comments
 
LVL 22

Accepted Solution

by:
rspahitz earned 500 total points
ID: 35089237
Is this the error line:


                    .cell(3, 5).Value = Me.txtRangeName.Value

did you try to pluralize cellS?
0
 

Author Comment

by:ssmith94015
ID: 35089286
Fixed that, but still get the error.  I did change the first value of the cells all to 0 as the data needs to go into the same row.
0
 

Author Comment

by:ssmith94015
ID: 35089400
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

Open in new window

0
 

Author Closing Comment

by:ssmith94015
ID: 35089405
This was the first step toward success so I did need to change that.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 35089869
thx...Glad you were able to work through it :)
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question