+ Reply to Thread
Results 1 to 5 of 5

How do I run a forumla in a macro?

  1. #1
    Forum Contributor
    Join Date
    03-04-2008
    Location
    Ohio
    MS-Off Ver
    Office 2010
    Posts
    208

    How do I run a forumla in a macro?

    I'm writing a macro to clean up some data that we read in from a text file. My macro cleans up and sorts into columns, and I want to re-order the data in two columns from top to bottom. I was trying to paste this formula "=INDEX($A$1:$A$100,ROWS($A$1:$A$100)-ROWS($A$1:$A1)+1)" into a group of cells. But I'm getting a compile error. I've tried with, and without, quotes.

    Not sure what's wrong. Suggestions, or a simpler method?

    Thanks,

    -gshock

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe

    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor
    Join Date
    03-04-2008
    Location
    Ohio
    MS-Off Ver
    Office 2010
    Posts
    208
    Yes, that will do. That will do nicely. Thanks very much.

    What is the reason for
    Please Login or Register  to view this content.
    I don't understand the meaning of the "space" after the = and the "underscore."

    Thanks for the help.

    -gshock

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Instead of a long string of code you can use the space and underscore as a sort of carriage return to keep the code easier to read.

    Without the return the code would look like the below

    Please Login or Register  to view this content.
    VBA Noob

  5. #5
    Forum Contributor
    Join Date
    03-04-2008
    Location
    Ohio
    MS-Off Ver
    Office 2010
    Posts
    208
    Quote Originally Posted by VBA Noob
    Instead of a long string of code you can use the space and underscore as a sort of carriage return to keep the code easier to read.

    Without the return the code would look like the below

    Please Login or Register  to view this content.
    VBA Noob
    Great. Thanks for the help. I'm building "Macro City."

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1