Results 1 to 2 of 2

Macro Correction Needed to Remove Text and blanks

Threaded View

  1. #1
    Registered User
    Join Date
    05-26-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    65

    Macro Correction Needed to Remove Text and blanks

    All,

    I need a little help. Here's the code I have so far to move from the Before to After sheets I've attached. As you can see, I'm still new to this and I'm no where near correct. Can you help out? I need to get from Before to After.
    Sub BoxScore_Convert()
    '
    ' NBA BoxScore Upload Prep
    '
    Dim PathName As String
    Dim NewBook As String
    Dim CurrentWB As Workbook
    Dim Pic As Object
    Dim bottomA As Integer
    Dim rRow1 As Long
    Dim rRow2 As Long
    Dim rRow3 As Long
    Dim Officials As String
    Dim TeamTotal As String
    Dim Rng1 As Range
    Dim Rng2 As Range
    Dim Rng3 As Range
    Dim FindString As String
    Dim textCounter As Long
    Dim x As Long
    
    PathName = "C:\BoxScoreTest\"
    NewBook = Dir(PathName & "*.xls")
    Do While NewBook <> ""
      
    ' Set font and remove blanks
      Set CurrentWB = Workbooks.Open(PathName & NewBook, 0)
        With CurrentWB.ActiveSheet
            .Rows("1:30").Delete Shift:=xlUp
        With .UsedRange.Font
            .Name = "Verdana"
            .Size = 10
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .TintAndShade = 0
            .ThemeFont = xlThemeFontNone
            .ColorIndex = xlAutomatic
              
        bottomA = Range("A" & Rows.Count).End(xlUp).Row
        Officials = "Officials:"
        TeamTotal = "Team Totals"
        FindString = "Advanced Box Score Stats"
        textCounter = Application.CountIf(ActiveSheet.Range("A:E"), "Advanced Box Score Stats")
        For x = 1 To textCounter
            If Trim(FindString) <> "" Then
                With Sheets("Sheet1").Range("A:E")
                    Set Rng1 = .Find(What:=FindString, _
                                After:=.Cells(.Cells.Count), _
                                LookIn:=xlValues, _
                                LookAt:=xlWhole, _
                                SearchOrder:=xlByRows, _
                                SearchDirection:=xlNext, _
                                MatchCase:=False)
                    If Not Rng1 Is Nothing Then
                        rRow1 = Rng1.Row
                    End If
                End With
                With Sheets("Sheet1").Range("A" & rRow1 & ":A" & bottomA)
                    Set Rng2 = .Find(What:=TeamTotal, _
                                After:=.Cells(.Cells.Count), _
                                LookIn:=xlValues, _
                                LookAt:=xlWhole, _
                                SearchOrder:=xlByRows, _
                                SearchDirection:=xlNext, _
                                MatchCase:=False)
                    If Not Rng2 Is Nothing Then
                        rRow2 = Rng2.Row
                    End If
                End With
            End If
            Range(rRow1 & ":" & rRow2).EntireRow.Delete
        Next x
        
        With Sheets("Sheet1").Range("A1:A" & bottomA)
            Set Rng3 = .Find(What:=Officials, _
                        After:=.Cells(.Cells.Count), _
                        LookIn:=xlValues, _
                        LookAt:=xlWhole, _
                        SearchOrder:=xlByRows, _
                        SearchDirection:=xlNext, _
                        MatchCase:=False)
            If Not Rng3 Is Nothing Then
                rRow3 = Rng3.Row
            End If
            Range(rRow3 & ":" & rRow3 + 20).EntireRow.Delete
     
    For Each Pic In ActiveSheet.Pictures
    Pic.Delete
    Next Pic
    
    Range("A1:BZ500").SpecialCells(xlCellTypeBlanks).Delete Shift:=xlToLeft
    Range("A:A").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("A:A").Value = Range("B:B").Value
    Range("D6").Select
    
        End With
        End With
        End With
    
    CurrentWB.Close True
    NewBook = Dir()
    
    Loop
    End Sub
    
    ]
    201106120MIA-After.xls201106120MIA-Before.xls
    Last edited by Sweepin; 11-09-2013 at 12:26 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 03-09-2013, 04:30 AM
  2. Adding Text to another cell VB code (Help Tweeking code) (Excel 2007)
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-06-2012, 11:37 AM
  3. Code for email alerts from excel isn't working, wrong code possibly?
    By jessthorogood in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-27-2012, 01:45 AM
  4. Replies: 2
    Last Post: 03-17-2011, 08:55 PM
  5. Replies: 0
    Last Post: 10-06-2006, 09: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