Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Relative referencing??

  1. #1
    New Member
    Join Date
    May 2002
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hey!
    I'm v.new to macros & the like so i need some advise.
    I have a task i need to automate as I seem to have to do it manually 10 times a day.
    I just need help with the principle really - so, hypothetically, if i was recording a macro to just multiply cell A1*B1 in cell C1,; I could have a file that has just 5 rows with A & B values, but other files may has 20,0000 A & B values.
    What is the most efficient way to do this so after the macro runs I have no tidying up to do? - i say this as the way i would do it at the moment is to copy cell C1 through to C65536, and when i get a file with just 6 rows i have to clear the remaining 65531 cells!

  2. #2
    New Member
    Join Date
    Apr 2002
    Posts
    15
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    put this in c1 then fill down

    this will check if the a1 or b1 is empty if so it will make c1 empty
    if a1 and b1 have number in them then it will multiply them

    =IF(OR(A1="",B1=""),"",A1*B1)

  3. #3
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-05-03 01:11, Saddler wrote:
    Hey!
    I'm v.new to macros & the like so i need some advise.
    I have a task i need to automate as I seem to have to do it manually 10 times a day.
    I just need help with the principle really - so, hypothetically, if i was recording a macro to just multiply cell A1*B1 in cell C1,; I could have a file that has just 5 rows with A & B values, but other files may has 20,0000 A & B values.
    What is the most efficient way to do this so after the macro runs I have no tidying up to do? - i say this as the way i would do it at the moment is to copy cell C1 through to C65536, and when i get a file with just 6 rows i have to clear the remaining 65531 cells!
    Have a look @ the following;

    Sub Tester()

    [C1].FormulaR1C1 = "=RC[-2]*RC[-1]"
    [C1].AutoFill Destination:=Range("C1:C" & [A1].End(xlDown).Row)

    End Sub

    Assumes
    1) Data starts in A1 & B1
    2) No gaps in data columns

    This places the formula =A1*B1 in C1
    (Using R1C1 format)
    Uses AutoFill instead of copying
    Gets last Row from the VBA use of End(Xldown)
    The equavalent Keyboard command is
    Selecting a cell and pressing END then the
    arrow key...this takes you to the Last populated cell in the specified direction
    which in this case is Down.




    Kind Regards,
    Ivan F Moala From the City of Sails

  4. #4
    Board Regular
    Join Date
    Mar 2002
    Posts
    62
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Cheers Chaps!

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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