Solved

Add data to the end of a range

Posted on 2011-03-09
5
203 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now