Results 1 to 5 of 5

Run macro after cell data input

This is a discussion on Run macro after cell data input within the Excel Questions forums, part of the Question Forums category; Hello guys! This is my first post so forgive me if I do anything wrong here, hehe , ok on ...

  1. #1
    New Member
    Join Date
    Jan 2012
    Posts
    3

    Talking Run macro after cell data input

    Hello guys!
    This is my first post so forgive me if I do anything wrong here, hehe, ok on to my question/request:

    I want to run a macro that unhides 15 lines (line 20 to 35) when data is inputed on cell 'F6' and to run another macro called "search" (i have already finished this macro) which will fill in information on the unhidden lines from above.

    could you please help me on this?

    I am a rookie on VBA, so if you could go slow on me I would really apareciate it!

  2. #2
    Board Regular Trevor G's Avatar
    Join Date
    Jul 2008
    Location
    Tamworth, Staffordshire
    Posts
    5,456

    Default Re: Run macro after cell data input

    Welcome to the Forum LewWalker,

    You can use the On Change Event behind the worksheet. Select the worksheet tab and then use right mouse button, then at the top the left drop down change to Worksheet then the right drop down change to On Change

    In the space between the on change event and End Sub you would add in something like this..

    Code:
    If Range("F6")="What ever the contents needs to be Then"
    Rows("20:35").EntireRow.Hidden = False
    Call SearchMacroName
    End IF
    Trevor
    I am on a learning curve of life, I know a little but like to share what I have learnt with others.
    I am using Microsoft Office 2003 to 2010
    Please remember everyone here is a volunteer, so if you have had a reply to your thread be courteous and acknowledge this.

  3. #3
    Board Regular gaj104's Avatar
    Join Date
    Nov 2002
    Posts
    802

    Default Re: Run macro after cell data input

    Welcome to the board,

    The following code will do what you need:

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Address(0, 0) = "F6" Then
        Rows("20:35").Hidden = True
        Call SearchMe
    End If
    
    End Sub
    Note, Search is a reserved word so I would change your name to something different i.e. SearchMe in my example.

    Have a read of the following article how to implement the code:

    http://www.ozgrid.com/VBA/run-macros-change.htm

    Hope it helps
    graemejones.co.uk My website!

  4. #4
    New Member
    Join Date
    Jan 2012
    Posts
    3

    Default Re: Run macro after cell data input

    Quote Originally Posted by Trevor G View Post
    Welcome to the Forum LewWalker,

    You can use the On Change Event behind the worksheet. Select the worksheet tab and then use right mouse button, then at the top the left drop down change to Worksheet then the right drop down change to On Change

    In the space between the on change event and End Sub you would add in something like this..

    Code:
    If Range("F6")="What ever the contents needs to be Then"
    Rows("20:35").EntireRow.Hidden = False
    Call SearchMacroName
    End IF
    Trevor!
    thanks alot for you answer! unfortunately i do not know what data will be inputter on the cell (if could be any number) so i think i will use gaj104's code...

    thanks any way! :D

  5. #5
    New Member
    Join Date
    Jan 2012
    Posts
    3

    Default Re: Run macro after cell data input

    Quote Originally Posted by gaj104 View Post
    Welcome to the board,

    The following code will do what you need:

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Address(0, 0) = "F6" Then
        Rows("20:35").Hidden = True
        Call SearchMe
    End If
    
    End Sub
    Note, Search is a reserved word so I would change your name to something different i.e. SearchMe in my example.

    Have a read of the following article how to implement the code:

    http://www.ozgrid.com/VBA/run-macros-change.htm

    Hope it helps
    gaj104!
    thanks alot for your answer i think this is what i need!!
    and dont worry about the "search" word.. my macro names are in spanish so it will not affect the preformance of excel, thanks for the tip anyway!

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
  •  


DMCA.com