Consulting

Results 1 to 5 of 5

Thread: Solved: Adding to values together within a cell programatically

  1. #1

    Solved: Adding to values together within a cell programatically

    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

    [VBA]Range("A5").Value = CustomerDetails.Range("A6").Value + i[/VBA]

  2. #2
    Maybe helps
    [vba]
    i = 1
    Range("A5").Value = CustomerDetails.Range("A6").Value
    Range("A5").Value = Range("A5").Value + i
    [/vba]

  3. #3
    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

    [VBA]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[/VBA]

  4. #4
    Works for me
    [VBA]
    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
    [/VBA]

  5. #5
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,198
    Location
    [vba]Range("A5").Value = CustomerDetails.Range("A6").Value[/vba]
    In this part are you refering to the sheet CustomerDetails?

    If you are then it should be...

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

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

    [vba]Range("A5").Value = Range("A6").Value[/vba]
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •