ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   question about syntax in a simple macro... (https://www.excelbanter.com/excel-discussion-misc-queries/117357-question-about-syntax-simple-macro.html)

Dave F

question about syntax in a simple macro...
 
I just recorded the following macro:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11/3/2006 by df78700
'

'
Cells.Select
Range("A8").Activate
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End Sub

I'm trying to select the entire worksheet and then create a new workbook and
paste all the cell values (not formulas) into that new workbook. This seems
to work fine, however, Range("A8") confuses me: obviously the range of an
entire XL worksheet is not one cell!

What am I missing here?
--
Brevity is the soul of wit.

Don Guillett

question about syntax in a simple macro...
 
try
Cells.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues
End Sub


--
Don Guillett
SalesAid Software

"Dave F" wrote in message
...
I just recorded the following macro:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11/3/2006 by df78700
'

'
Cells.Select
Range("A8").Activate
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End Sub

I'm trying to select the entire worksheet and then create a new workbook
and
paste all the cell values (not formulas) into that new workbook. This
seems
to work fine, however, Range("A8") confuses me: obviously the range of an
entire XL worksheet is not one cell!

What am I missing here?
--
Brevity is the soul of wit.




Earl Kiosterud

question about syntax in a simple macro...
 
Dave,

This is about activating a cell and selecting cells. Lots of cells can be
selected, but only one, the white one, is active. You've activated A8, but
a selection has never been made So without a selection, the Copy method puts
all the cells on the clipboard. If you add something like
Range("A7").Select first, then Range("A8").Activate will also select A8, and
your macro will copy/paste only A8. Better yet, change Range("A8).Activate
to Range("A8").Select.

--
Earl Kiosterud
www.smokeylake.com
-----------------------------------------------------------------------
"Dave F" wrote in message
...
I just recorded the following macro:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11/3/2006 by df78700
'

'
Cells.Select
Range("A8").Activate
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End Sub

I'm trying to select the entire worksheet and then create a new workbook
and
paste all the cell values (not formulas) into that new workbook. This
seems
to work fine, however, Range("A8") confuses me: obviously the range of an
entire XL worksheet is not one cell!

What am I missing here?
--
Brevity is the soul of wit.




Dana DeLouis

question about syntax in a simple macro...
 
Hi.

ActiveSheet.Copy

Will copy the sheet to a new Workbook.

If you select a small area, you will see that 1 cell is always "active,"
even though you have selected more than 1 cell.
--
HTH :)
Dana DeLouis
Windows XP & Office 2003


"Dave F" wrote in message
...
I just recorded the following macro:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11/3/2006 by df78700
'

'
Cells.Select
Range("A8").Activate
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End Sub

I'm trying to select the entire worksheet and then create a new workbook
and
paste all the cell values (not formulas) into that new workbook. This
seems
to work fine, however, Range("A8") confuses me: obviously the range of an
entire XL worksheet is not one cell!

What am I missing here?
--
Brevity is the soul of wit.





All times are GMT +1. The time now is 07:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com