+ Reply to Thread
Results 1 to 3 of 3

Keeping a row reference in the assigned Macros automaticlly after Adding/removing Row/Rows

  1. #1
    Registered User
    Join Date
    10-17-2015
    Location
    Kaunas, Lietuva
    MS-Off Ver
    2013
    Posts
    2

    Question Keeping a row reference in the assigned Macros automaticlly after Adding/removing Row/Rows

    In the same sheet are assigned over 10 Macros with hide rows with different ranges for example : for one macro is Range("314:314,326:343,353:357,368:369,372:376").Select Selection.EntireRow.Hidden = True; for the the other Range("314:314,322:327,334:342,344:346,348:357,368:369,372:376" ).Select Selection.EntireRow.Hidden = True and so on.....
    For this reason is important to me how to find a proper way how to make keep the ranges with a row reference in modules automaticlly after adding or removing row/rows because rows will move down or up not by keeping the rows reference for assigned macro. Now everytime i need to go through all 10 macros to change ranges after adding/removing row/rows. it takes a lot of time and a lot of chances to be mistaken.Thanks!

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Keeping a row reference in the assigned Macros automaticlly after Adding/removing Row/

    You could use variables.
    Please Login or Register  to view this content.
    The value of the variables rng1, 2 and 3 never change in this macro and there is no need for the Select, Selection. The little dot connector tells VBA that the following is a dependent of the former. Gets rid of the flicker and flash.
    Last edited by JLGWhiz; 12-20-2015 at 02:12 PM.

  3. #3
    Registered User
    Join Date
    10-17-2015
    Location
    Kaunas, Lietuva
    MS-Off Ver
    2013
    Posts
    2

    Re: Keeping a row reference in the assigned Macros automaticlly after Adding/removing Row/

    There is an idea to keep the ranges with a row text in modules in the same position automaticlly after adding or removing row/rows because the assigned rows (with text) moving up or down. for example if will be added row 304 so the former row 304 with my needed text will be moved up into row 305. For this reason in the module {("305:380").Select Selection.EntireRow.Hidden = True} the row 305 now will be hidden but in reality i need this row but perhaps is not possible to force the vba to understand that i need this row visible?

+ 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. Replies: 2
    Last Post: 11-12-2015, 11:13 PM
  2. Replies: 7
    Last Post: 08-05-2014, 05:34 AM
  3. Assigned Macros don't stay assigned?!?
    By paesu57 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-10-2014, 10:49 AM
  4. [SOLVED] Always reference cell C2, regardless of adding or removing rows/columns
    By gray-ish in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-13-2012, 04:21 PM
  5. Excel 2007 advanced macros assigned to button to Hide/Unhide Rows
    By newbie77 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-08-2011, 01:05 PM
  6. Keeping macro cell references when adding/removing rows/columns
    By dlukas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-07-2009, 03:16 PM
  7. Replies: 3
    Last Post: 03-07-2006, 03:30 PM

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