[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Add data to the end of a range

Posted on 2011-03-09
5
Medium Priority
?
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 22

Accepted Solution

by:
rspahitz earned 2000 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

649 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