range selection problem

  • Thread starter Thread starter derekc
  • Start date Start date
D

derekc

i have a sheet with bunches of data, i have a button when pressed t
copy the first 23 rows of data, opens a new sheet them copies it over
then i have to return the the first sheet and search for certain dat
to copy over as well. i have the code but for some reason th
original selected 23 rows stay selected, i even put

Range("A1").Select

to selecta cell to get rid of the highlighted stuf, then it searche
for the data and copies it, but some reason it doesnt highlight th
next set of data.

Range("A23:Q23").Select

this command selects a1 and copies that. i tell it not to though, here
what i have.

If (G23 > 1) Then Range("A23:Q23").Select
Selection.Copy
ActiveWindow.ActivateNext
ActiveWindow.WindowState = xlNormal
ActiveSheet.Range("A23:Q23").Select
ActiveSheet.Paste

End Sub

thats without the range("a1.... which would be right about IF.
is there somehting else i can put in to unselect the origina
highlighted data so it can then highlight something else. ive tried

Application.CutCopyMode = False

also. any ideas
 
Sub Tester10()
Dim sh As Worksheet
Set sh = ActiveSheet
ActiveWindow.ActivateNext
Set sh2 = ActiveSheet
If sh.Range("G3").Value > 1 then
sh.Range("A23:Q23").Copy Destination:= _
sh2.Range("A23:Q23")
End if
sh.Parent.window.Activate
End Sub

Should avoid the need to highlight.
 
gave error on last line of code.

sh.Parent.window.Activate

thanks for help thoug
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top