Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I have the following code below. I have a total of 7 seperate worksheets within a workbook that I want this macro to run on. Essentially I want to be able to copy any row that has a number in column B. This macro works great for one worksheet, but I want to be able to take all 7 sheets and combine into one sheet. Thanks in advance. Sub CopyRowsWithNumbersInB() Dim X As Long Dim LastRow As Long Dim Source As Worksheet Dim Destination As Worksheet Dim RowsWithNumbers As Range Set Source = Worksheets("Clinical Nursing") Set Destination = Worksheets("Sheet2") With Source LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row For X = 2 To LastRow If IsNumeric(.Cells(X, "B").Value) And .Cells(X, "B").Value < "" Then If RowsWithNumbers Is Nothing Then Set RowsWithNumbers = .Cells(X, "B") Else Set RowsWithNumbers = Union(RowsWithNumbers, .Cells(X, "B")) End If End If Next If Not RowsWithNumbers Is Nothing Then RowsWithNumbers.EntireRow.Copy Destination.Range("A1") End If End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
sumif across multiple sheets in excel 2007 based on a condition | Excel Worksheet Functions | |||
Sum across sheets based on a condition | Excel Worksheet Functions | |||
Reading Values Between Sheets Based On The Condition | Excel Programming | |||
Referencing Across Sheets Based On Condition | Excel Worksheet Functions | |||
Merge ranges based on condition | Excel Programming |