ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VB Code Question (https://www.excelbanter.com/excel-programming/388610-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!


Jim Jackson

VB Code Question
 
Refer to sheet2 as Sheets(2) etc.
--
Best wishes,

Jim


"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!


Vergel Adriano

VB Code Question
 
Stan,

Try something like this

Sub test()

Sheets("Sheet1").Range("A1").Cut Destination:=Sheets("Sheet2").Range("A1")
With Sheets("Sheet2")
.Range("A1").Copy Destination:=.Range("B1")
.Range("A1").Copy Destination:=.Range("C1")
End With

End Sub


--
Hope that helps.

Vergel Adriano


"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!



All times are GMT +1. The time now is 09:21 AM.

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