Ask Experts Questions for FREE Help !
Ask
    rmccafferty's Avatar
    rmccafferty Posts: 15, Reputation: 1
    New Member
     
    #1

    Jul 27, 2008, 04:34 PM
    Cell references within VBA in an Excel macro
    In a macro in Excel I want to refer to a cell where the user entered a number. I want that number to be the row number for the macro to move to. (I will then select the entire row and copy it to row 1, which I know how to do).

    How can I tell the macro which row to go to, using the number that has, in this case, been entered into cell A3? That is, if the user entered the number 11 in cell A3, how to I tell the macro to to to A11?

    I assume I need to use a variable. If so, I know how to declare the variable, but not the syntax for assigning a value to the variable in Excel or now to use that variable within a reference to a cell location.

    Thanks,
    Robert
    [email protected]
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #2

    Jul 27, 2008, 11:46 PM
    In the VBA code, the following line would do what you want:

    Range("A3").Select

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Auto-Macro in Excel [ 4 Answers ]

Hi, I have a lot of macros built-in Excel, but when I want to update the certain data , I have to run them individually each time. Do you know anyway I can auto-run these macros? Thanks for any help.

Recording a macro in Excel [ 2 Answers ]

Need a macro that will select the cell one place to the left, edit the content, hit enter, and then move to cell below where started and repeat to end of column (last cell with a value). Example: 123-456789 is format of cell to be edited - need to remove the hyphen. Someone had created it...

How to Automate a macro in excel [ 4 Answers ]

A program logs files at random in txt. abc_log.txt (example) When new info. Is added to the txt file,manualy activate macro and it does what it suppose to do, all OK there. Is there a way a macro code or excel, or perhaps a BAT program can be made to simply "detect" when new data is added...


View more questions Search