+ Reply to Thread
Results 1 to 11 of 11

Help with vba coding debugging - I just cant see where I am going wrong ;(

Hybrid View

  1. #1
    Registered User
    Join Date
    09-20-2014
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    98

    Help with vba coding debugging - I just cant see where I am going wrong ;(

    I think I have been staring at this too long - just cant see where I am going wrong with the coding below. The whole spreadsheet is aimed at helping the teachers at my school with their tracking etc.

    Sheets 26 to 28 have either M or F in Column G, which is filtered in the first part of the coding.

    If I run it with 'M' as criteria it works great, as soon as I change to 'F' it does all I ask, but I get a RunTime Error 13 'type mismatch' and the end.

    YET if I run Part 1 and Part 2 separately they work well.

    Any ideas?

    Thanks



    Sub filtergirls()
    Application.ScreenUpdating = False
    
    'PART 1
    Range(ActiveCell.Address).Name = "StartCell"
    
          Dim q As Integer
        For q = 26 To Worksheets.Count
            With Worksheets(q)
        .AutoFilterMode = False
        .Range("B4:DZ" & .Cells.Find("*", , , , 1, 2).Row).AutoFilter Field:=6, Criteria1:="F"
                    End With
        Next q
                 Sheets("Analysis AUT").Range("$M$2").Value = "(Girls Only)"
                 Sheets("Analysis SPR").Range("$M$2").Value = "(Girls Only)"
                 Sheets("Analysis SUM").Range("$M$2").Value = "(Girls Only)"
                          Application.DisplayStatusBar = True
        Application.StatusBar = "Filter: GIRLS"
           Dim cell As Range
        Application.ScreenUpdating = False
        
    
    'part 2
            Dim b As Integer
        For b = 5 To 17
        
        Worksheets(b).Activate
        ActiveSheet.Unprotect Password:="Teacher1971"
         For Each cell In Intersect(Sheets(b).UsedRange, Range("C103:DZ103"))
            cell.EntireColumn.Hidden = cell.Value = 1 And Not IsEmpty(cell)
        Next cell
        ActiveSheet.Protect Password:="Teacher1971", UserInterFaceOnly:=True, AllowFiltering:=True, AllowSorting:=True
        Next b
        
       Worksheets(3).Activate
    
    Application.GoTo "StartCell"
    
    
    End Sub

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Help with vba coding debugging - I just cant see where I am going wrong ;(

    Hi,

    You really need to upload the workbook so that we may see your request in context.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    09-20-2014
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    98

    Re: Help with vba coding debugging - I just cant see where I am going wrong ;(

    It is too big to attach

    Can I link to an external copy on googledrive or something?

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Help with vba coding debugging - I just cant see where I am going wrong ;(

    Can't you remove all but a representative sample of your data? We don't need zillions of rows or sheets, just any data that is relevant and which is needed by the macro.

  5. #5
    Registered User
    Join Date
    09-20-2014
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    98

    Re: Help with vba coding debugging - I just cant see where I am going wrong ;(

    I have uploaded to here as too big for Excel Forum. I hope that is allowed.

    HTML Code: 

  6. #6
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2505
    Posts
    2,792

    Re: Help with vba coding debugging - I just cant see where I am going wrong ;(

    I have uploaded to here as too big for Excel Forum. I hope that is allowed.
    Zip the file and upload the zipped file.

  7. #7
    Registered User
    Join Date
    09-20-2014
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    98

    Re: Help with vba coding debugging - I just cant see where I am going wrong ;(

    Zipped it is still 1.7mb which is too big.

    The macro applies to all sheets, I suppose I could edit it down to a sample for you...

  8. #8
    Registered User
    Join Date
    09-20-2014
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    98

    Re: Help with vba coding debugging - I just cant see where I am going wrong ;(

    AHA!

    While simplifying to upload for you guys to see I spotted and corrected the issue!

    Thanks.....while you only helped indirectly, you actually helped me solve it for myself!

    Ha

  9. #9
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2505
    Posts
    2,792

    Re: Help with vba coding debugging - I just cant see where I am going wrong ;(

    If you could post the solution so someone with a similar problem might be helped.

    Please click the Thread Tools drop down box above your first post and choose solved.

  10. #10
    Registered User
    Join Date
    09-20-2014
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    98

    Re: Help with vba coding debugging - I just cant see where I am going wrong ;(

    The loop was referencing a sheet without the M/F on it. Not sure why it worked with the M - should have failed on both.

     For b = 5 To 17
    should have read

     For b = 6 To 17

  11. #11
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2505
    Posts
    2,792

    Re: Help with vba coding debugging - I just cant see where I am going wrong ;(

    Okay, thanks.

    Second request:
    Please click the Thread Tools drop down box above your first post and choose solved.

+ 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. macro coding help (i have no background in coding)
    By notgoodenough in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-05-2014, 10:22 PM
  2. [SOLVED] Vb macro coding for transpose - complete coding?
    By Dharani Suresh in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 08-02-2013, 11:16 PM
  3. [SOLVED] Vb macro coding for transpose - complete coding?
    By Dharani Suresh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-02-2013, 05:04 AM
  4. Wrong coding or RANDBETWEEN is wrong?
    By zbor in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 07-31-2013, 10:01 AM
  5. [SOLVED] CheckBox coding to work with ComboBox coding
    By JimExcel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-05-2013, 12:23 PM
  6. Coding and Reverse Coding a Questionnaire
    By lorr3 in forum Excel General
    Replies: 2
    Last Post: 11-18-2012, 06:43 PM
  7. [SOLVED] Implant macro coding into ASP coding
    By Sam yong in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-15-2005, 06:05 AM

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