LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Zak Zak is offline
external usenet poster
 
Posts: 144
Default Code not working correctly

Hi,

I have two problems with the same code - I am finding that when i run the
macro, it copies the specified cells into the report sheet but it doesnt copy
from the 1st cell/row under the column header row.. (for examples, intead of
copying from C2 it copies from C3 onwards.. but there is a filter on so C2 is
not actually C2 but something else - C**- dont know if this matters).

The code from where it selects the cells from: (before this bit of the code
there are some conditions - if cell =blank or 0 then hide, dont know if this
will affect anything.)

'selects columns
For Each cell In Range("Y2:Y65536")
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 & "," _
& "S" & cell.Rows.Row & ":" & "Y" & cell.Rows.Row & "," _
& "AJ" & cell.Rows.Row & ":" & "AJ" & cell.Rows.Row).Select
'paste them to other sheet
Selection.Copy
Worksheets("Report").Activate
If Range("A1") = "" Then
Worksheets("GTS_C_SI").Activate
Range("C1:D1,G1:H1,S1:Y1,AJ1").Select
Selection.Copy
Worksheets("Report").Activate
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteAll
Application.CutCopyMode = False
Else
Range("A65536").End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteAll
Application.CutCopyMode = False
End If
Worksheets("GTS_C_SI").Activate
End If
End If
Next cell
Worksheets("Report").Activate
Cells.Select
Cells.EntireColumn.AutoFit
Cells.EntireRow.AutoFit
Range("A1").Select
Worksheets("GTS_C_SI").Activate
With Application
.DisplayAlerts = True
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub


The second problem I am having is with the below line:

Range("C1:D1,G1:H1,S1:Y1,AJ1").Select

Everything in the above is fine just that i dont want it to select S1:Y1 -
which selects everything between S&Y. I want it to just select S and Y. I
have tried changing the code to just S1 and Y1 and numerous other things but
i get strange results! like the info is there but the column header is
missing and info all mixed up.

Please help. Thanks!
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SUM formula not working correctly Kim Excel Worksheet Functions 1 November 1st 07 03:45 PM
code not working correctly phil-rge-ee Excel Programming 5 June 8th 07 12:26 PM
Cursor not working correctly LSOT Excel Discussion (Misc queries) 4 November 1st 05 04:45 PM
VBE Window not working correctly STEVE BELL Excel Programming 6 June 10th 05 05:36 PM
Column find code not working correctly Todd Huttenstine Excel Programming 2 November 16th 04 09:18 PM


All times are GMT +1. The time now is 09:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"