Solved

Add data to the end of a range

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

867 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

21 Experts available now in Live!

Get 1:1 Help Now