+ Reply to Thread
Results 1 to 5 of 5

Macro: number of rows to select changes based on input

  1. #1
    Registered User
    Join Date
    05-15-2017
    Location
    Groningen
    MS-Off Ver
    Office Excel 2013
    Posts
    4

    Macro: number of rows to select changes based on input

    Hi all,

    So I have recorded a macro which works exactly like I want it based on my input. My input now has data in row 2 to 287.
    The goal is to change this input every time and then the macro performs exactly the same tasks. How do I make sure that when the input has less or more rows (it does always start at 2 but may end at for example row 267 or 297) that it indeed performs the same tasks?

    Below is the code. The data is attached.

    Please Login or Register  to view this content.
    Hope you guys can help!

    Kind regards,
    Sandra

    Edit: could it have something to do with the way I select the data? I now select the rows that contain data by using Ctrl+Shift+arrow down
    Attached Files Attached Files
    Last edited by Sandraa4218; 06-19-2017 at 05:32 AM.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Macro: number of rows to select changes based on input

    Mouse bounce.

  3. #3
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Macro: number of rows to select changes based on input

    You also have references to Rows 253 & 246 in there so what's the relationship between them and 287 in this example? If your last row was 300 what do those change to? 266 & 259??


    Also:
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

  4. #4
    Registered User
    Join Date
    05-15-2017
    Location
    Groningen
    MS-Off Ver
    Office Excel 2013
    Posts
    4

    Re: Macro: number of rows to select changes based on input

    Hi Lazarus, my apologies. I have corrected my post.
    The code deletes certain rows two times. First it deletes all the rows that contain "blank" and then all the rows that contain #DIV/0! in one column and 0 in another column. I want this because I do not want to include them in my further process. Or is it a bad idea to delete rows for the macro?

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Macro: number of rows to select changes based on input

    Not a bad idea - it's just you referred to row number 287 as the last row in your example but the code also refers to the other rows I mentioned. I can't imagine these are fixed so there must be some way to determine which rows you want when, for example, the last row is 300 rather than 287.

    Thank you for the edit to the first post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Create a specific number of consecutive rows based on row count input
    By goodlite in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-18-2017, 09:17 AM
  2. Need Macro to Duplicate Rows based on input
    By faist001 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-08-2016, 08:26 AM
  3. Replies: 2
    Last Post: 10-13-2015, 05:05 PM
  4. vba code to copy number of rows in based on the input message
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-12-2014, 12:38 AM
  5. Replies: 3
    Last Post: 11-07-2013, 11:40 AM
  6. [SOLVED] a macro to find number based on user input
    By J4kub in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-14-2013, 05:59 PM
  7. Macro to Filter Copy the rows based on input
    By souvick in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2011, 02:47 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