+ Reply to Thread
Results 1 to 7 of 7

Specific VB Code for Select Case & Worksheet Event Change please

  1. #1
    Registered User
    Join Date
    08-09-2011
    Location
    London
    MS-Off Ver
    Excel 2007 onwards
    Posts
    4

    Smile Specific VB Code for Select Case & Worksheet Event Change please

    Hi all,
    What I'm trying to do is change the contents of a cell if that particular column is not relevant (based on Type).. I don't want to put a formula in the actual cell as I need it for possible data entry.. Is there a procedure or macro that would do this more effectively?..

    My column headers are (the information is stored in rows):
    Column A: Set
    Cloumn B: Type
    Column C: Unit

    Columns: D through to H are only relevant to certain Types and those that are not, I have used conditional formatting so if the result is N/A the cell is 'blocked out' (which I have to enter manually).. I would like Excel to 'lookup'? Type and if A, then block out *cell reference* and *cell reference* as not applicable and if it's Type B then block out this *cell reference* and *cell reference* etc.. The main problem being there are 5 different types..

    Please help!.. I'm useless at coding!!.. Please see the below, hence my change in my request for someone to please write the code for me as I'm struggling!!..
    Last edited by mally1975; 08-11-2011 at 05:45 AM. Reason: Moderator request

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Can anyone help with code??

    Something like this

    Please Login or Register  to view this content.
    This is worksheet event code, which means that it needs to be
    placed in the appropriate worksheet code module, not a standard
    code module. To do this, right-click on the sheet tab, select
    the View Code option from the menu, and paste the code in.

  3. #3
    Registered User
    Join Date
    08-09-2011
    Location
    London
    MS-Off Ver
    Excel 2007 onwards
    Posts
    4

    Re: Can anyone help with code??

    [QUOTE=Bob Phillips;2577135]

    Thank you for your help.. I keep getting compile errors with this, such as:

    'End With without With'
    'End If without If'

    I think this looks like it will work but what am I doing wrong to get these errors?.. Your advice is most appreciated!! .. Wish I blinking understood VBA code a little more!!

  4. #4
    Registered User
    Join Date
    05-13-2011
    Location
    New Zealander in London
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Can anyone help with code??

    You'll receive errors just copying and pasting the above code - you need to complete it. The Select Case requires an End Select where the 'etc is for a start, hence the errors you're receiving above.

    I think this is a 'starter for 10' to get you going. If you're after somebody to write the whole thing for you, please advise and this can be done too.

  5. #5
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Can anyone help with code??

    I omitted an 'End Select' statement after the line 'etc.
    Last edited by Bob Phillips; 08-10-2011 at 06:53 AM.

  6. #6
    Registered User
    Join Date
    08-09-2011
    Location
    London
    MS-Off Ver
    Excel 2007 onwards
    Posts
    4

    Re: Can anyone help with code??

    Quote Originally Posted by tarquinious View Post
    You'll receive errors just copying and pasting the above code - you need to complete it. The Select Case requires an End Select where the 'etc is for a start, hence the errors you're receiving above.

    I think this is a 'starter for 10' to get you going. If you're after somebody to write the whole thing for you, please advise and this can be done too.
    lol There is that, however, I don't wish to be lazy and how could I ever thank the person enough who took the time to do it!!.. Saying that, I think I might have to admit I can't do it and ask someone who can.. To add to my problems yet further, another column has been added so each Type now needs two separate columns showing "N/A" lol..
    Last edited by mally1975; 08-10-2011 at 07:09 AM.

  7. #7
    Registered User
    Join Date
    08-09-2011
    Location
    London
    MS-Off Ver
    Excel 2007 onwards
    Posts
    4

    Re: Can anyone help with code??

    OK lol I admit defeat.. Please may I have some help with the full code.. I admit I'm a bit useless with VBA and don't know what to do here.. I'm completely lost!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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