View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default .usedrange in closed workbook

range("A1").Select works for me. range("A1").Activate only changes the
activecell - but select should reduce the selection.

--
Regards,
Tom Ogilvy

"Ken McLennan" wrote in message
...
G'day there again, Tom,

I don't see why PasteSpecial Values shouldn't work (unless you have
merged
cells)


I'm not sure now myself why it didn't work. I can't even recall
what messages I got. I intend to have a play with it tonight to see
what's going on.


I've now gone back and had a look at that version of my code.
Guess what? It wasn't a bug in Microsoft's code it was a typo on my part
(dammit!!). Actually it was a couple of instances of the same typo -
that's what happens when you mistype something and then copy & paste it.

I had this loop:

With ThisWorkbook

.Sheets.Add after:=.Sheets(.Sheets.Count)
.Sheets(.Sheets.Count).Name = newName(srcBk.Name)

srcPg.UsedRange.Copy

.Sheets(.Sheets.Count).Range("A1").PasteSpecial _
Paste:=xlPasteValuesAndNumberFormats
.Sheets(.Sheets.Count).Range("A1").PasteSpecial _
Paste:=xlPasteFormats
Application.CutCopyMode = False
End With

Except that where I use ".Sheets(.Sheets.Count)" I had "Sheets
(Sheets.Count)" behind the "after:=" and ".Sheets(Sheets.Count)"
everywhere else.

Now that I have periods in where they're supposed to be it works
fine.

Only thing now is that after pasting, all of the pasted range
stays selected. I've tried using range("A1").select, but without
success. The entire pasted range still remains selected. I think I may
have to select a cell outside the range, or activate the sheet first.
Any suggestions?

It's not really a biggy at the moment, but I'm sure to find a
client who'll cut rather than copy and things will stuff up from there.

See ya
Thanks for your help
Ken McLennan
Qld, Australia