Goalexcel
Board Regular
- Joined
- Dec 28, 2020
- Messages
- 101
- Office Version
- 2016
- Platform
- 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.
The file is below link Laur Brown sent you 1 item
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
The file is below link Laur Brown sent you 1 item