+ Reply to Thread
Results 1 to 2 of 2

Automate a macro and assign it to a sheet

  1. #1
    Registered User
    Join Date
    10-23-2019
    Location
    Switzerland
    MS-Off Ver
    2016
    Posts
    1

    Automate a macro and assign it to a sheet

    Hi everyone,

    I am quite new to this and I have been trying some things here and there.
    I am now making a list of movie titles and I created sheets for each genre.

    So let me explain a bit.

    I have two sheets ;

    1st sheet contains two columns; one for the movie titles and the other for the genres.
    2nd sheet is my "Action" movies sheet where I want all the Action movies from the 1st sheet to appear.

    My issue is that once I import movies from the 1st sheet, it creates blank rows in the 2nd.

    I applied this :

    Sub sbDelete_Rows_IF_Cell_Is_Blank()
    Dim lRow As Long
    Dim iCntr As Long
    lRow = 20
    For iCntr = lRow To 1 Step -1
    If Trim(Cells(iCntr, 1)) = “” Then
    Rows(iCntr).Delete
    End If
    Next
    End Sub


    and it works well, but I need to press F5 in my 2nd sheet each time I add an Action movie title to my 1st sheet.

    So my question is : Is there a way to automate this macro so that each time I add a title it automatically deletes the blank rows ? Also do I need to assign it to my sheet if it was created there in the first place ?


    Sorry if I was unclear english is not my primary language but don't hesitate to ask any questions.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Automate a macro and assign it to a sheet

    You could use a Worksheet_Change event - but why are you creating blank rows?
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

+ 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. Trying to assign macro button that runs on a different sheet in the workbook
    By MrWhiskey in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-21-2017, 03:12 PM
  2. Macro to Automate sheet by taking values from different tabs
    By kierra_kk in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-18-2017, 02:33 AM
  3. Macro to automate monthly spreadsheet pulling dates and info from Sheet1 to Sheet 2
    By macaulaymetals in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 09-16-2015, 05:55 PM
  4. How to automate sheet formatting via Macro
    By aiwnjoo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-11-2014, 04:47 AM
  5. Add a picture and assign a macro everytime a new sheet is inserted
    By bcn1988 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-16-2013, 02:35 PM
  6. Automate excel to assign color code to values in table
    By A.Patel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-09-2012, 09:39 PM
  7. Macro to automate VLookup on new sheet
    By PeterSV in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-27-2008, 10:33 AM

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