Results 1 to 5 of 5

Thread: VBA Reference problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Aug 2014
    Posts
    6
    Location

    VBA Reference problem

    Hi Guys,

    My first post so big welcome.

    I have been using your tips for quite long and normally getting what I needed using the newbie 'step-by-step' and self learn practise but now I'm stuck.

    I'm not too good with programing in VBA for my own, more like recording and stuff I'm familiar with so please be gentle

    The problem I'm having is here:
    Having this code what does work etc I'm willing to use another sheet (tab) from the same workbook to refer to (instead 'G2' I need tab colled 'Personel' and G2 from there).

    Above is an first step only. Now I need to refer to range of cells, not to only one of them and I believe the code is wrong to do it so.
    I would name it something like that:
    If Cell from my range (B4:C9) contains one of from G1:G10 (located at 'Personel' tab) then Cell.Interior.ColorIndex = 3.

    Basically there are 8 groups of personel with 10 names in each of them and I have a nice list created, now I would like to refer to the list while filling they payslips using the names. And if for eg. gary works for IT and I have typed his name it's blue, etc[B].

    Private Sub Worksheet_Change(ByVal Target As Range)
    Set MyPlage = Range("B4:C9")
        For Each Cell In MyPlage
    
            If Cell.Value = Range("G2") Then
                Cell.Interior.ColorIndex = 3
            End If
    
        Next
    End Sub
    Last edited by Bob Phillips; 08-13-2014 at 01:59 AM. Reason: Added VBA tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •