+ Reply to Thread
Results 1 to 6 of 6

Getting compile error 1004

Hybrid View

mso3 Getting compile error 1004 02-15-2015, 01:58 AM
shg Re: Getting compile error 1004 02-15-2015, 02:23 AM
mso3 Re: Getting compile error 1004 02-15-2015, 03:03 AM
shg Re: Getting compile error 1004 02-15-2015, 02:50 PM
mso3 Re: Getting compile error 1004 02-15-2015, 07:16 PM
mso3 Re: Getting compile error 1004 02-16-2015, 06:46 PM
  1. #1
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Getting compile error 1004

    Hi friends,
    If I delete a value in column ‘C’ Information sheet then I want to enter a remark “L” on semester1 and semester2 sheets. The range is column ‘c:g; k:o and so on as per the tables on it. I’m getting compile error 1004.

    Any help will be appreciated.

    Thanking you,
    Attached Files Attached Files
    Sincerely,

    mso3

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Getting compile error 1004

    Could you post the code?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Getting compile error 1004

    Hi SHG,
    The code is already in the sheet module of information sheet. No problem, I'm pasting it here for your reference.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim c As Range
    If Target.Column <> 3 Then Exit Sub
    With Target
    If .Count = 1 Then
    Select Case .Column
    Case 3
    Select Case .Value
    Case ""
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    'Target.Offset(, -1).Value = "Left"
    Range("d" & .Row).Resize(, 1).Value = "L"
    Range("e" & .Row).Resize(, 8).Value = ""
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    End Select
    End Select
    End If
    End With
    With Range("a4:a90")
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    .FormulaR1C1 = "=IF(RC[2]>0,SUM(MAX(R3C:R[-1]C),1),"""")"
    .Formula = .Value
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    End With
    
        Application.ScreenUpdating = False
        Application.EnableEvents = False
        If Not Intersect(Target, Range("c:c")) Is Nothing Then
            For Each c In Worksheets("Semester1").Range("b10:b90")
            If c.Value = "" Then
                c.Range("c").Resize(, 5).Value = "L" 'getting error 1004
                c.Range("k").Resize(, 5).Value = "L" 'getting error 1004
                c.EntireRow.Hidden = True
            End If: Next c
        End If
            If Not Intersect(Target, Range("c:c")) Is Nothing Then
            For Each c In Worksheets("Semester2").Range("b10:b90")
                If c.Value = "" Then
                c.Resize.EntireRow = ""
                c.EntireRow.Hidden = True
            End If: Next c
        End If
        Application.EnableEvents = True
        Application.ScreenUpdating = True
        MsgBox "done"
    End Sub
    Thanking you.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Getting compile error 1004

    Maybe ...

    Private Sub Worksheet_Change(ByVal Target As Range)
      Dim cell          As Range
    
      With Target
        If .Column <> 3 Then Exit Sub
        
        On Error GoTo Oops
        Application.EnableEvents = False
    
        If .Count = 1 Then
          If IsEmpty(.Value) Then
            .EntireRow.Range("D1").Value = "L"
            .EntireRow.Range("E1:L1").ClearContents
          End If
        End If
      End With
    
      With Range("A4:A90")
        .FormulaR1C1 = "=IF(RC[2]>0,SUM(MAX(R3C:R[-1]C),1),"""")"
        .Value = .Value
      End With
    
      For Each cell In Worksheets("Semester1").Range("B10:B90").Cells
        If IsEmpty(cell.Value) Then
          cell.EntireRow.Range("C1:G1, K1:O1").Value = "L"
          cell.EntireRow.Hidden = True
        End If
      Next cell
    
      For Each cell In Worksheets("Semester2").Range("B10:B90").Cells
        If IsEmpty(cell.Value) Then
          cell.EntireRow.ClearContents
          cell.EntireRow.Hidden = True
        End If
      Next cell
    
    Done:
      Application.EnableEvents = True
      Exit Sub
    
    Oops:
      MsgBox "Oops"
      Resume Done
    End Sub
    Last edited by shg; 02-15-2015 at 03:08 PM.

  5. #5
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Getting compile error 1004

    Hi SHG,
    Excellent! I have made a little amendment in the code. It's working fine but only a problem is that it changes all the rows which are blank. I want the action for the cell in which I delete a value 'Information' sheet and output should be for the same student on semester1 and semester2 sheet instead for all rows which are blank.

    For example:
    If I delete a value from cell c5 Information sheet then
    only the second student has a remark 'L' and hide that row.

    Private Sub Worksheet_Change(ByVal Target As Range)
      Dim cell          As Range
    
      With Target
        If .Column <> 3 Then Exit Sub
        
        On Error GoTo Oops
        Application.EnableEvents = False
    
        If .Count = 1 Then
          If IsEmpty(.Value) Then
          Target.Offset(, -1).Font.ColorIndex = 3
            .EntireRow.Range("D1").Value = "L"
                    .EntireRow.Range("D1").Font.ColorIndex = 3
            .EntireRow.Range("E1:L1").ClearContents
          End If
        End If
      End With
    
      With Range("A4:A90")
        .FormulaR1C1 = "=IF(RC[2]>0,SUM(MAX(R3C:R[-1]C),1),"""")"
        .Value = .Value
      End With
    
      For Each cell In Worksheets("Semester1").Range("B10:B90").Cells
        If cell.Value = "" Then
              cell.EntireRow.Range("C1:G1, K1:O1").Value = "L"
              cell.EntireRow.Range("C1:G1, K1:O1").Font.ColorIndex = 3
          cell.EntireRow.Hidden = True
        End If
      Next cell
    
      For Each cell In Worksheets("Semester2").Range("B10:B90").Cells
        If cell.Value = "" Then
          cell.EntireRow.Range("C1:G1, K1:O1").Value = "L"
          cell.EntireRow.Range("C1:G1, K1:O1").Font.ColorIndex = 3
          cell.EntireRow.Hidden = True
        End If
      Next cell
    
    Done:
      Application.EnableEvents = True
      Exit Sub
    
    Oops:
      MsgBox "Oops"
      Resume Done
    End Sub
    Thank you.
    Last edited by mso3; 02-15-2015 at 09:08 PM. Reason: Post a amended code

  6. #6
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Getting compile error 1004

    Hi SHG,
    Thank you for your guidance to achieve the target of 'L' remark. To avoide the programmatic error in my result sheet I want to add one more condition to the code for giving 'L' remark. There are marks in the column 'd'.

    So the additional condition for 'Lremark on semester1 and semester2 sheet is:

    if column D has a value 'marks' then
    (in short if column B = "" and column D contains value (marks) then only the remark 'L' should be given)
    I think that this will solve the problem.

    Sorry for trouble. Please do this little amendment to get perfect output and close the thread. I have to complete my result sheet at the earliest so I want to solve it at the earliest.

    Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Compile error 1004
    By mukeshbaviskar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-08-2014, 10:35 PM
  2. Excel macro (compile error. syntax error.) error
    By salar_younis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2014, 06:11 AM
  3. [SOLVED] Compile Error in Hidden Module and Compile Error: Can't find project or library
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-10-2013, 07:03 PM
  4. compile error: compile error expected
    By odeno in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-11-2008, 04:30 PM
  5. VBAProject name compile error, not defined at compile time
    By Matthew Dodds in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-13-2005, 03:20 PM

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