Results 1 to 2 of 2

Check a range of cells and perform tasks

Threaded View

  1. #1
    Registered User
    Join Date
    06-09-2011
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    1

    Check a range of cells and perform tasks

    Hi All,
    I am trying to check the range of F5:F7 whether it contains a value or not, if it is a value, I will extract the sheets according to its respective range in E5:E7. The workbook where the worksheets is extracted is in range A1. I have tested my coding to extract the worksheets from the workbook and so on, it works, except for the part that I highlighted. This is an addition so it goes through the for loop and if instead of putting the name of the sheets manually. Please take a look and give me a feedback. Thanks in advance

    
     Sub test()
     
     
     Dim Bk As String
     Dim ws As Worksheet
     Dim strFldrPath As String
     Dim mycheck As Boolean
     Dim wk As String
       
       
       
       Bk = Sheets("Sheet1").Cells(1, 1).Value
    strFldrPath = Sheets("Sheet1").Cells(2, 1).Value
    wk = Sheets("Sheet1").Cells(i, 5).Value
     
    'opening Workbook
    
    Workbooks.Open Filename:=strFldrPath
    
     'Removes all worksheets in this workbook so that new ones can be pulled in
        Application.DisplayAlerts = False
        For Each ws In ThisWorkbook.Worksheets
            If ws.Name <> "Sheet1" And ws.Name <> "Sheet2" Then
                ws.Delete
            End If
        Next ws
        Application.DisplayAlerts = True
    
        
        Set wb = Workbooks(Bk)
        
    
     
    
    endrange = 10
    
    For i = 5 To endrange
     
    mycheck = Sheets("Sheet1").Range("F" & i).Value = 1
    
    If mycheck = True Then wb.Sheets(wk).Copy After:=Workbooks("Book1 .xls").Sheets("Sheet1")
    
    
    
    Next i
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

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