Results 1 to 2 of 2

Thread: Code Error
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Oct 2019
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Code Error

    Could someone please help me out with this, im pretty green with coding, and the orange part is getting an error, thanks

    Sub Empl_Load()
    Dim EmpRow As Long
    Dim EmpCol As Long
    With Sheet1
    If .Range("B5").Value = Empty Then
    MsgBox "Please enter a valid Employee from the drop down list"
    Exit Sub
    End If
    .Range("B1").Value = True 'Set Employee Load To True
    EmpRow = .Range("B5").Value
    For EmpCol = 1 To 28
    .Range(Sheet2.Cells(1, EmpCol).Value).Value = Sheet2.Cells(EmpRow, EmpCol).Value
    Next EmpCol
    .Shapes("Group 67").Visible = msoFalse
    .Shapes("Group 66").Visible = msoCTrue
    .Range("B1").Value = False 'Set Employee Load To False
    .Range("B6").Value = False 'Set New Employee To False
    Show_EmplPic
    End With
    End Sub

  2. #2
    Board Regular MARK858's Avatar
    Join Date
    Nov 2010
    Location
    Southern England
    Posts
    11,234
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    2 Thread(s)

    Default Re: Code Error

    Code:
    .Range(Sheet2.Cells(1, EmpCol).Value)
    This part is wrong unless you have a range address in Sheet2.Cells(1, EmpCol), on what sheet do you want
    Code:
    Sheet2.Cells(EmpRow, EmpCol).Value
    placed? and what is in
    Code:
    Sheet2.Cells(1, EmpCol).Value
    ?

    There might be more questions depending what your answers to the 2 questions are.
    Test VBA on a copy of your data (remember you can't normally reverse the action)

    Please follow the forum Rules and Guidelines & please use Code tags around your code i.e. [CODE]your code[/CODE]

    To post a screenshot try one of these links
    MrExcel HTML Maker, RoryA addin (Win & Mac) or Borders-Copy-Paste

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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