Results 1 to 15 of 15

Using Number of Rows in a Column to Make a Range for a Different Column

Threaded View

  1. #1
    Registered User
    Join Date
    11-14-2022
    Location
    England
    MS-Off Ver
    MS365 (PC) Version 2308
    Posts
    59

    Question Using Number of Rows in a Column to Make a Range for a Different Column

    Hi all,

    I am very new to VBA after spending the vast majority of my time in Excel writing formula's instead. (And I'm by no means amazing at that)
    However something I can do via formula, seems to be very hard for me to achieve in VBA.

    Basically I would like a macro that finds the last cell of a column, in my attached example workbook that's Row 26 in Column D, then uses that number 26 to make a new range. Eg E2:E26. (Where D, E, 2 and 26 are all variable)
    I have be advised by a friend of mine to make sure all variables are kept at the top of the code so they can easily be changed if needs be rather than trawling through code.
    Equally they advised me to make sure I refer to the workbook and sheet, so the macro can be used in other places and with consequences while running. (Similarly I avoid select and activate where possible)

    I have attached a sample workbook and included a basic example of what I'm after. (And one of my latest failings)

    Finally it's worth mentioning that I have tried this with loop and although it works, it's not practical to use in my original file which has over 1000+ rows so it would be a lot of volatile random numbers.
    I more hope to make a range based on the number of rows in a different column and then later refer to that new range to manipulate with copy etc.

    Cheers in advance
    EricDonk

    Edit: I have tried to find an answer to this using all sorts, but everything I saw online doesn't actually do what I'm after.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Concatenate Text in Column B Split in Multiple Rows for Each Number in Column A
    By zaska in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-23-2020, 03:51 AM
  2. [SOLVED] Loop rows and make a Range null if criteria met in defined Column
    By KEDENNIS in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-03-2016, 09:55 AM
  3. [SOLVED] Copy rows/range and paste n number of times based on last used cell in Column A
    By skonduru in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-29-2016, 02:30 PM
  4. Replies: 7
    Last Post: 08-09-2015, 05:07 PM
  5. [SOLVED] Delete rows if column A matches number and meets condition in another column
    By stokiejames09 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-05-2014, 05:03 PM
  6. [SOLVED] count the number of times each string appears in a column and make a summary column
    By intothewild in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-04-2012, 08:02 AM
  7. How to make a formulae repeat every x number of rows in the same column
    By speko191 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-07-2011, 02:25 AM

Tags for this Thread

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