PDA

View Full Version : Solved: Adding to values together within a cell programatically



bopo
01-10-2009, 12:35 PM
Hi

I know this is very simple, its simply a syntax and forgetfulness problem, as I haven't used VBA for a long time, basically I'm getting an 'Object is required' error, and i = 1

Range("A5").Value = CustomerDetails.Range("A6").Value + i

omnibuster
01-10-2009, 12:46 PM
Maybe helps

i = 1
Range("A5").Value = CustomerDetails.Range("A6").Value
Range("A5").Value = Range("A5").Value + i

bopo
01-10-2009, 12:52 PM
Thanks for the help, but I'm still getting an error, I think its because I'm inserting a new row or something, can anyone see anything wrong with this logically

Note last line is comment, I was trying different methods and trying to identify which line of code was creating the error

Sub NewCustomerRecords()



Sheets("CustomerDetails").Select

Worksheets("CustomerDetails").Rows("4:4").Select

Selection.End(xlDown).Select
Selection.EntireRow.Insert



Range("A5").Value = CustomerDetails.Range("A6").Value
' Range("A5").Value = Range("A5").Value + 1


End Sub

omnibuster
01-10-2009, 01:07 PM
Works for me

Sub NewCustomerRecords()
Dim i As Single
i = 1
Sheets("CustomerDetails").Select
Worksheets("CustomerDetails").Rows("4:4").Select
Selection.End(xlDown).Select
Selection.EntireRow.Insert
Range("A5").Value = Sheets("CustomerDetails").Range("A6").Value + i
End Sub

georgiboy
01-10-2009, 01:32 PM
Range("A5").Value = CustomerDetails.Range("A6").Value
In this part are you refering to the sheet CustomerDetails?

If you are then it should be...

Range("A5").Value = Sheets("CustomerDetails").Range("A6").Value
As Omnibuster has already changed it to.

If you are already selecting the sheet CustomerDetails then it could be...

Range("A5").Value = Range("A6").Value