Results 1 to 9 of 9

Vlookup in VBA

Threaded View

Crispy85 Vlookup in VBA 07-10-2013, 10:31 AM
Norie Re: Vlookup in VBA 07-10-2013, 10:39 AM
Crispy85 Re: Vlookup in VBA 07-10-2013, 10:41 AM
gjcase Re: Vlookup in VBA 07-10-2013, 10:43 AM
gjcase Re: Vlookup in VBA 07-10-2013, 10:48 AM
Crispy85 Re: Vlookup in VBA 07-10-2013, 10:52 AM
catchnanan Re: Vlookup in VBA 07-10-2013, 11:03 AM
Norie Re: Vlookup in VBA 07-10-2013, 11:05 AM
Crispy85 Re: Vlookup in VBA 07-10-2013, 11:12 AM
  1. #1
    Forum Contributor
    Join Date
    06-14-2013
    Location
    jk
    MS-Off Ver
    Excel 2007
    Posts
    326

    Vlookup in VBA

    Hi Guys,

    I'm busy trying to solve my problem for a couple of days now and i can't find how to fix it.

    My VBA-script is as following:

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Intersect(Target, [D1]) Is Nothing Then
            Rows.Hidden = False
            Columns.Hidden = False
            Select Case [D1]
                Case 1
                Case 2
                    Rows("6:6").Hidden = True
                    Rows("7:8").Hidden = True
                    Rows("11:11").Hidden = True
                    Rows("13:13").Hidden = True
                    Columns("K:K").Hidden = True
                    Columns("M:M").Hidden = True
                Case 3
                    Rows("6:6").Hidden = True
                    Rows("7:8").Hidden = True
                    Rows("10:11").Hidden = True
                    Rows("13:15").Hidden = True
                    Columns("k:l").Hidden = True
                    Columns("m:M").Hidden = True
                Case 4
                    Rows("6:6").Hidden = True
                    Rows("7:8").Hidden = True
                    Rows("10:11").Hidden = True
                    Rows("13:15").Hidden = True
                    Columns("k:l").Hidden = True
                    Columns("m:M").Hidden = True
                Case Else
                    Exit Sub
            End Select
        End If
    End Sub
    *The hidden columns in case 3 and 4 are the same, but it's just an example.

    Now what goes wrong is the value in D1. I want to retrieve it via VLOOKUP, from a value that has been entered in C1.

    If i take the formula out and simply enter the value 1, 2, 3 or 4, the script works fine.
    I also tried to put it between tags like this:

    Case "1"
    Case "2"
    Case "3"
    Case "4"

    But that didn't make a difference.

    Could someone explain me what i'm doing wrong?

    Note; the use of VLOOKUP is kinda neccessary.

    Thank you guys!

    EDIT* btw; my VLOOKUP in D1 looks like this:

    =IF(RIGHT(C1,1)="T","",VLOOKUP(C1,'Activity Database'!$A:$I,9,0))
    Last edited by Crispy85; 07-10-2013 at 10:33 AM. Reason: Additional info

Thread Information

Users Browsing this Thread

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

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