Results 1 to 2 of 2

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

  1. #1
    New Member
    Join Date
    Oct 2019
    Post Thanks / Like
    0 Post(s)
    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
    End With
    End Sub

  2. #2
    Board Regular MARK858's Avatar
    Join Date
    Nov 2010
    Southern England
    Post Thanks / Like
    1 Post(s)
    2 Thread(s)

    Default Re: Code Error

    .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
    Sheet2.Cells(EmpRow, EmpCol).Value
    placed? and what is in
    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