Consulting

Results 1 to 5 of 5

Thread: Macro to copy cell without leaving cell

  1. #1

    Macro to copy cell without leaving cell

    Hi
    I'm trying to have a macro copy a cell to another cell in the same worksheet without leaving that cell

    Example:
    HTML Code:
    Private Sub Worksheet_activate()
    Range("A5").Select
    ActiveWindow.FreezePanes = True
    x = Range("A" & Rows.Count).End(xlUp).Row
     '  copy this cell to P7
    Range("A" & x + 1).Select 
    End Sub

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    Range("P7").value = x
    or
    Range("P7").value = Range("A" & Rows.Count).End(xlUp).value

    depending on what value you're wanting.
    Last edited by p45cal; 09-30-2018 at 01:05 PM.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    Hi p45cal,
    thanks for the quick response
    I can't get the first on to work,

    I made a test spreedsheet with numbers 1 to 15 in A1:A15
    I changed P7to C1
    I put the cursor on A12 and ran the macro
    HTML Code:
    Sub test()
    Range("P7").value = x
    end sub
    C1 was empty
    What did I do wrong?


    BUT>> the second one is perfect for what i need.

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    Quote Originally Posted by selfteaching View Post
    C1 was empty
    What did I do wrong?
    You didn't assign anything to x as you had in your first message.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  5. #5
    It took awhile to figure out that I need something like
    HTML Code:
    Selection.Value
    I"ll remember it better because i had to figure it out
    Thank you for your help and giving me a learning tool.

    I also like your name

Posting Permissions

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