+ Reply to Thread
Results 1 to 4 of 4

VBA - Using RANGE function - Feeding Parms Problem

  1. #1
    Registered User
    Join Date
    08-07-2007
    Posts
    14

    VBA - Using RANGE function - Feeding Parms Problem

    I have searched here and I found some threads which I thought might help but after trying I came up empty so I figured I'd start one and put my code up.

    I've gone from Green Screen Programming back to the GUI side and now have to learn the VBA for EXCEL....

    Task: On a worksheet which has a dynamically changing # of rows, insert 2 columns, set their width, and insert a formula into the range.

    - For example if there are 30 rows the variable RowsCounted will house 30. If there are 20,000 then RowsCounted will have the value of 20,000. I want to say Range("F3:RowsCounted".Formula = "FormulaGoesHere"

    Here is the specific line which is giving me problems:
    Please Login or Register  to view this content.
    Here is what I have thus far (it all works except being able to put something into the range):

    Please Login or Register  to view this content.
    Edited to reflect the code tags
    Last edited by TreasureCat; 08-09-2007 at 02:29 PM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    Try this instead

    Please Login or Register  to view this content.
    Martin

  3. #3
    Registered User
    Join Date
    08-07-2007
    Posts
    14
    Thanks for the quick reply I tried that before, and I copied and pasted what you put to be sure that I didn't fat finger it. This is the error msg that I get:

    Runtime error 1004
    Method 'Range' of object '_Global' failed


    I tried this and finally got it:
    Range("F3:F" & RowsCounted).Formula = "=ROUND((RC[4]/RC[-1]),0)"
    Quote Originally Posted by mrice
    Try this instead

    Please Login or Register  to view this content.
    Last edited by TreasureCat; 08-07-2007 at 04:07 PM.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello TreasureCat,

    Welcome to the forum. Please follow the forum rules for posting. If you don't, you may find that the moderators have locked or removed your post. You can read them by clicking this link Forum Rules.

    Thank you,
    Leith Ross

+ 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