Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Steve
 
Posts: n/a
Default A simple maco . . .

Would appreciate some help with a simple macro.

I'd like a keystroke-activated macro to do the following in whatever
cell I happen to be in:

insert "text1" into the cell I activate the macro from,

move one cell to the right and insert "text2",

select and copy the contents of both cells to the clipboard,

end the macro with the original cell active and the dashed line around
both cells indicating they were copied to the clipboard.

I tried recording the keystrokes to do this, but the recorded macro
includes specific cell addresses. I need something that uses some form
of relative cell addressing.

Thanks.

Steve
  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Hi Steve,

Sub Macro1()
With ActiveCell
.Value = "text1"
.Offset(0, 1) = "text2"
.Resize(1, 2).Copy
End With
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Steve" wrote in message
...
Would appreciate some help with a simple macro.

I'd like a keystroke-activated macro to do the following in whatever
cell I happen to be in:

insert "text1" into the cell I activate the macro from,

move one cell to the right and insert "text2",

select and copy the contents of both cells to the clipboard,

end the macro with the original cell active and the dashed line around
both cells indicating they were copied to the clipboard.

I tried recording the keystrokes to do this, but the recorded macro
includes specific cell addresses. I need something that uses some form
of relative cell addressing.

Thanks.

Steve



  #3   Report Post  
Steve
 
Posts: n/a
Default

Thanks Bob, it works great. I'm just starting to learn about macros,
appreciate the guidance.

Steve

Bob Phillips wrote:

Hi Steve,

Sub Macro1()
With ActiveCell
.Value = "text1"
.Offset(0, 1) = "text2"
.Resize(1, 2).Copy
End With
End Sub


  #4   Report Post  
JE McGimpsey
 
Posts: n/a
Default

Just an alternative:

Public Sub Macro2()
With ActiveCell.Resize(1, 2)
.Value = Array("text1","text2")
.Copy
End With
End Sub

In article ,
"Bob Phillips" wrote:

Sub Macro1()
With ActiveCell
.Value = "text1"
.Offset(0, 1) = "text2"
.Resize(1, 2).Copy
End With
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ploting dates against a calendar and not as a simple events Barb Reinhardt Charts and Charting in Excel 2 January 22nd 05 02:41 AM
Simple formula doesn't quite add up circeo Excel Discussion (Misc queries) 3 January 17th 05 09:04 PM
How do I convert an existing MS Excel worksheet tracking a simple. NOTANYJOE Excel Discussion (Misc queries) 1 January 4th 05 02:07 AM
How do I convert an existing MS Excel worksheet tracking a simple. [email protected] Excel Discussion (Misc queries) 0 January 4th 05 12:53 AM
Please help correct a simple error lwhite New Users to Excel 1 December 9th 04 09:39 PM


All times are GMT +1. The time now is 06:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"