+ Reply to Thread
Results 1 to 8 of 8

Loop help needed to repeat macro so that it works for every completed cell in a column

  1. #1
    Registered User
    Join Date
    07-16-2018
    Location
    devon
    MS-Off Ver
    2010
    Posts
    6

    Red face Loop help needed to repeat macro so that it works for every completed cell in a column

    Hi Guys

    I have managed to create a macro that links to a data validation drop down list, however I can only get it to work by looking at one cell at a time. As the column will be using the data validation in every row, I would ideally like it to auto repeat until a blank cell is found.

    Here is what I have come up with so far:-

    ub CRG()

    ActiveCell.Offset(0, 1).Select


    End Sub

    Sub DRSS_Service()

    ActiveCell.Offset(0, 4).Select

    End Sub


    Sub Member_of_Staff()

    ActiveCell.Offset(0, 13).Select

    End Sub


    Sub T_and_D()

    ActiveCell.Offset(0, 16).Select

    End Sub

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("Q3")) Is Nothing Then
    Select Case Range("Q3")
    Case "A CRG": CRG
    Case "The DRSS Service": DRSS_Service
    Case "A Member of Staff": Member_of_Staff
    Case "Training or Development": T_and_D
    End Select
    End If

    Any help in getting the 'Private Sub Worksheet_Change(ByVal Target As Range)' to work on each and every cell in column Q would be greatly appreciated.
    Last edited by luebob; 07-17-2018 at 04:15 AM. Reason: to make title more relevant

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,884

    Re: Trying to repeat macro for each cell in a column

    Try changing Range("Q3") to Range("Q:Q")
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    07-16-2018
    Location
    devon
    MS-Off Ver
    2010
    Posts
    6

    Re: Trying to repeat macro for each cell in a column

    I am afraid that didn't work :-(. It came up with a Runtime error 13 - Type mismatch.

    Any other ideas????

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,884

    Re: Trying to repeat macro for each cell in a column

    Can you attach a copy of your file. De-sensitize the data if necessary. Explain in detail what you want to do referring to specific cells, rows and columns.

  5. #5
    Registered User
    Join Date
    07-16-2018
    Location
    devon
    MS-Off Ver
    2010
    Posts
    6

    Re: Loop help needed to repeat macro so that it works for every completed cell in a column

    Hi Mumps1

    Thank you for offering to help.

    What I am trying to do is create a macro that will run each time a selection is chosen from the drop down menu, that takes the user to the first
    column of section that relates to that choice(i.e. if the feedback relates to CRG and this is selected from the dropdown menu, the user is taken
    to column R).

    On every occasion the user will remain on the same row.

    So far I have managed to link the drop down menu to the macro that takes the user to an adjacent active cell using active cell offset, however I
    can only get the VBA containing the case statement that links the drop down menu and to the corresponding macro to work with a static cell reference
    for the drop down. I have been unable to work out how to get it to work on all the cells in the column containing data, or get it to loop until it
    reaches a blank cell reference.

    I am so close, yet still so far :-(
    Attached Files Attached Files

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,884

    Re: Loop help needed to repeat macro so that it works for every completed cell in a column

    Try:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-16-2018
    Location
    devon
    MS-Off Ver
    2010
    Posts
    6

    Re: Loop help needed to repeat macro so that it works for every completed cell in a column

    Thank you soooooo much. I really appreciate your help with this. That is super. :D

    Once again I was over thinking things.

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,884

    Re: Loop help needed to repeat macro so that it works for every completed cell in a column

    You are very welcome.

+ 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. [SOLVED] How do you tweak the VBA code to repeat a macro for entire column
    By Deepanshu_S in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-27-2017, 05:12 PM
  2. Replies: 4
    Last Post: 05-03-2013, 04:35 PM
  3. [SOLVED] VBA to detect next empty cell in column and add formula, then repeat for next column, ...
    By Marijke in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-17-2013, 07:28 AM
  4. Making a macro repeat for all values in column and leave results on WS2
    By jackuspi2010 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-19-2013, 12:34 PM
  5. Loop to repeat macro on column cells
    By samy_mero in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-08-2010, 10:46 PM
  6. repeat macro until empty space in next column
    By Sabba Efie in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-15-2006, 04:10 PM
  7. How do I repeat a column when printing in a macro?
    By TaxMan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-25-2005, 05:06 PM

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