Copying across values based on criteria
On Jan 21, 8:47*am, Zak wrote:
Please can you help on the below? also, while i was trying to fix the code
myself (having no luck!) i noticed a couple of things missing/not functioning
properly, for example, additional to if anything is 0 then hide these rows i
also want to say if anything is blank then hide these rows (within the same
column -Z). When i ran this macro although it wasnt pulling across the right
info i noticed that what it did copy across into the new sheet was literally
just one row from the spredsheet as opposed to all the selected information
to be diaplayed in a formatted way in another sheet.
please help! thanks.
"Zak" wrote:
I modified the code as below but its not doing what i want it to...
I added a few more columns that i want it to extract - i dont think i have
done it correctly!
Also, in the "sheet" where i want it to put this information i have stated
"report" but i would like for it to just put the information into a new sheet
because the "report" sheet may not always be there.. how do i do this?
thanks alot.
Sub tracker1()
Dim cell As Range
* * 'Hides each row if Z = "0"
* * For Each cell In Range("Z2:Z65536")
* * If cell.Value "0" Then
* * cell.Rows.Hidden = True
* * End If
* * Next cell
* * 'selects columns
* * For Each cell In Range("Z2:Z65536")
* * If cell.Rows.Hidden = False Then
* * If cell.Value "" Then
* * Range("C" & cell.Rows.Row & "D" & "G" & "H" & "T" & "U" & "V" & "W" &
"X" & cell.Rows.Row & "," _
* * & "Y" & cell.Rows.Row & "Z" & "AM" & cell.Rows.Row).Select
* * 'paste them to other sheet
* * Selection.Copy _
* * Worksheets("Report").Range("A1")
* * End If
* * End If
* * Next cell
End Sub
"GTVT06" wrote:
Hello,
You can do something along the lines of this for the code:
Dim cell As Range
* * 'Hides each row if Z = "0"
* * For Each cell In Range("Z2:Z65536")
* * If cell.Value = "0" Then
* * cell.Rows.Hidden = True
* * End If
* * Next cell
* * 'selects columns
* * For Each cell In Range("Z2:Z65536")
* * If cell.Rows.Hidden = False Then
* * If cell.Value "" Then
* * Range("H" & cell.Rows.Row & ":" & "O" & cell.Rows.Row & "," _
* * & "X" & cell.Rows.Row & ":" & "Y" & cell.Rows.Row).Select
* * 'paste them to other sheet
* * Selection.Copy _
* * Worksheets("Sheet2").Range("A1")
* * End If
* * End If
* * Next cell
As for the Colors and the Borders, you can use conditional formating
to color or border the cell if the cell is <""- Hide quoted text -
- Show quoted text -
Sorry about that, I added a quick fix so it will paste the data in
multiple rows on the other sheet. I will look into your other request
and get back with you shortly
Dim cell As Range
'Hides each row if Z = "0"
For Each cell In Range("Z2:Z65536")
If cell.Value = "0" Then
cell.Rows.Hidden = True
End If
Next cell
'selects columns
For Each cell In Range("Z2:Z65536")
If cell.Rows.Hidden = False Then
If cell.Value "" Then
Range("H" & cell.Rows.Row & ":" & "O" & cell.Rows.Row & "," _
& "X" & cell.Rows.Row & ":" & "Y" & cell.Rows.Row).Select
'paste them to other sheet
Selection.Copy
Worksheets("Sheet2").Activate
Range("A65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Worksheets("Activities").Activate
End If
End If
Next cellDim cell As Range
'Hides each row if Z = "0"
For Each cell In Range("Z2:Z65536")
If cell.Value = "0" Then
cell.Rows.Hidden = True
End If
Next cell
'selects columns
For Each cell In Range("Z2:Z65536")
If cell.Rows.Hidden = False Then
If cell.Value "" Then
Range("H" & cell.Rows.Row & ":" & "O" & cell.Rows.Row & "," _
& "X" & cell.Rows.Row & ":" & "Y" & cell.Rows.Row).Select
'paste them to other sheet
Selection.Copy
Worksheets("Sheet2").Activate
Range("A65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
Application.CutCopyMode = False
rng = Worksheets("Sheet2").Range("A65536").End(xlUp).Add ress
Worksheets("Activities").Activate
End If
End If
Next cell
|