On Jan 21, 2:02*pm, Zak <Z...@discussions.microsoft.com> wrote:
> I tried the code and it doesnt work! it went to error and highlighted:
>
> "Worksheets("Activities").Activate", maybe because the "activities"
> worksheet doesnt exist?
>
> Also, i dont think you have put a code for 'if anything in column Z is
> blank'..(additional to 'if anything is >0') how do i do that?
>
> thanks for all your help.
>
>
>
> "GTVT06" wrote:
> > On Jan 21, 3:50 am, Zak <Z...@discussions.microsoft.com> 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 -
>
> > Here is the revised version with the revised Columns to copy.paste and
> > also the revisions for the "Report" sheet.
>
> > With Application
> > * * .DisplayAlerts = False
> > * * .EnableEvents = False
> > * * .ScreenUpdating = False
> > End With
> > Dim cell As Range
> > * * Dim n As Single
> > * * Dim exist As Boolean
> > * *For n = 1 To Sheets.Count
> > * * * * Sheets(n).Activate
> > * * * * If ActiveSheet.Name = "Report" Then
> > * * * * exist = True
> > * * * * End If
> > * * * * Next n
> > * * If exist = False Then
> > * * Sheets("Activities").Select
> > * * Sheets.Add
> > * * ActiveSheet.Name = "Report"
> > * * End If
> > * * Worksheets("Activities").Activate
> > * * '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" & cell.Rows.Row & "," _
> > * * & "G" & cell.Rows.Row & ":" & "H" & cell.Rows.Row & "," _
> > * * & "T" & cell.Rows.Row & ":" & "Z" & cell.Rows.Row & "," _
> > * * & "AM" & cell.Rows.Row & ":" & "AM" & cell.Rows.Row).Select
> > * * 'paste them to other sheet
> > * * Selection.Copy
> > * * Worksheets("Report").Activate
> > * * If Range("A1") = "" Then
> > * * Range("A1").Select
> > * * ActiveSheet.Paste
> > * * Else
> > * * * * Range("A65536").End(xlUp).Offset(1, 0).Select
> > * * ActiveSheet.Paste
> > * * Application.CutCopyMode = False
> > * * End If
> > * * Worksheets("Activities").Activate
> > * * End If
> > * * End If
> > * * Next cell
> > With Application
> > * * .DisplayAlerts = True
> > * * .EnableEvents = True
> > * * .ScreenUpdating = True
> > End With- Hide quoted text -
>
> - Show quoted text -
Sorry Rename the Activites sheet to the appropriate name of the sheet
that has all of the data that we are copying from. Not sure what the
name is... And I'll modify to hide all blanks also, I forgot about
that
|