ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VB Code Question (https://www.excelbanter.com/excel-discussion-misc-queries/141309-vbulletin-code-question.html)

Stan

VB Code Question
 
Can someone assist me with some Excel VB code?

In the example below, I want to cut the date from the current worksheet
(Sheet1) and paste it into multpile cells in another worksheet (Sheet2)
within the same workbook.

What is the best way to reference each worksheet? I tried Sheet2! but that
didn't work for me.

Range("A1").Select
Selection.Cut Destination:=Range("A1,B1,C1") 'this needs to be pasted in
a new worksheet within the same workbook.


Many thanks if you can help!

Gord Dibben

VB Code Question
 
Stan

Try this.

Sub foo()

ActiveSheet.Range("A1:C1").Cut _
Destination:=Sheets("Sheet2").Range("A1")

End Sub

You could use Sheets("Sheet1").Range("A1:C1") and run it from any sheet.


Gord Dibben MS Excel MVP

On Wed, 2 May 2007 11:34:00 -0700, Stan wrote:

Can someone assist me with some Excel VB code?

In the example below, I want to cut the date from the current worksheet
(Sheet1) and paste it into multpile cells in another worksheet (Sheet2)
within the same workbook.

What is the best way to reference each worksheet? I tried Sheet2! but that
didn't work for me.

Range("A1").Select
Selection.Cut Destination:=Range("A1,B1,C1") 'this needs to be pasted in
a new worksheet within the same workbook.


Many thanks if you can help!



Don Guillett

VB Code Question
 
try this from anywhere in the workbook.

Sub copycutcell()
With Sheets("sheet4").Range("a1")
.Copy Sheets("sheet3").Range("a1:c1")
.Clear
End With
End Sub

--
Don Guillett
SalesAid Software

"Stan" wrote in message
...
Can someone assist me with some Excel VB code?

In the example below, I want to cut the date from the current worksheet
(Sheet1) and paste it into multpile cells in another worksheet (Sheet2)
within the same workbook.

What is the best way to reference each worksheet? I tried Sheet2! but
that
didn't work for me.

Range("A1").Select
Selection.Cut Destination:=Range("A1,B1,C1") 'this needs to be pasted
in
a new worksheet within the same workbook.


Many thanks if you can help!




All times are GMT +1. The time now is 11:12 AM.

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