Copy specif cell if condition is met to another sheet

Goalexcel

Board Regular
Joined
Dec 28, 2020
Messages
101
Office Version
  1. 2016
Platform
  1. Windows
I'm completely stuck and needs help with some fresh code. Need to do.
1.- Copy numbers from sheet Data, to another sheet, for example sheet 14, only column C only 4 numbers that cell no has color
2.- Create macro for the rest 8 sheets.

VBA Code:
Sub new1()

'declaring the worksheets, Sheet2 and Sheet3 should be changed to match your sheet names

Dim ws As Worksheet
        Set ws = Sheets("Sheet15")

    Dim wsTwo As Worksheet
       Set wsTwo = Sheets("Sheet11")
      
  'clearing out previous data in wsTwo
 
       wsTwo.Cells.Clear
      
'finding the last row and column for ws with data inside
  Dim lastRow As Integer
        lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row

    Dim lastColumn As Integer
        lastColumn = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
        

    ws.Range("B2:C2").Copy
    wsTwo.Range("B2:C2").PasteSpecial xlPasteAll
    Application.CutCopyMode = False
    
  'beginning our loop from the last row and moving upwards.
 
    Dim rowCounterWsTwo As Integer
         rowCounterWsTwo = 2

    For rowNum = lastRow To 2 Step -1
            If Cells(rowNum, lastColumn).DisplayFormat.Interior.Color = vbWhite = vbWhite Then
                ws.Range(Cells(rowNum, 1), Cells(rowNum, lastColumn)).Copy
                wsTwo.Range("B2:C2").Insert
                Application.CutCopyMode = False
                rowCounterWsTwo = rowCounterWsTwo + 1
            End If
    Next rowNum

End Sub

1685938655034.png



1685938615123.png


The file is below link Laur Brown sent you 1 item
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,215,084
Messages
6,123,029
Members
449,092
Latest member
ikke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top