Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro to copy current cell

Hi,

When I write a macro to copy D1, it always copies D1.

If I move to E1, I would like it to copy E1 (the cell I'm on).

Does anyone know how to present this (cells and rows) as a variable in
a macro?

Thanks a bunch,

Michele

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Macro to copy current cell

You could use ActiveCell, rather than a specific cell. That would copy
what cell currently has the focus. Or is there something else you meant
by it?



*** Sent via Developersdex http://www.developersdex.com ***
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro to copy current cell

Hi Michele

Use ActiveCell
ActiveCell.Copy Sheets("Sheet2").range("A1")

Or Selection ?


--
Regards Ron de Bruin
http://www.rondebruin.nl



wrote in message oups.com...
Hi,

When I write a macro to copy D1, it always copies D1.

If I move to E1, I would like it to copy E1 (the cell I'm on).

Does anyone know how to present this (cells and rows) as a variable in
a macro?

Thanks a bunch,

Michele



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro to copy current cell

I tried your suggestion to use Active Cell, but now I get an error on
ActiveSheet.Paste. I'm basically, coping cell contents from one
spreadsheet to another based on the row I'm in. Here's a few of the
lines.

Workbooks.Open Filename:= _
"C:\Documents and Settings\Administrator\My
Documents\CustomSafety\010184641.xls"
Range("A11:B11").Select
Windows("Cust.xls").Activate
ActiveCell.Copy Sheets("CustomerList").Range("A1")
Windows("010184641.xls").Activate
ActiveSheet.Paste
Range("C11").Select
Windows("Cust.xls").Activate
Range("B6").Select
Application.CutCopyMode = False
Selection.Copy
Windows("010184641.xls").Activate
ActiveSheet.Paste

Thanks for replying.

Michele

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro to copy current cell

Hi

The example line I posted will copy the activecell in sheet2 cell A1
ActiveCell.Copy Sheets("Sheet2").Range("A1")

There is nothing on the clipboard now that's why you get the error
Tell us exactly what you want to do and we can change the macro for you



--
Regards Ron de Bruin
http://www.rondebruin.nl



wrote in message oups.com...
I tried your suggestion to use Active Cell, but now I get an error on
ActiveSheet.Paste. I'm basically, coping cell contents from one
spreadsheet to another based on the row I'm in. Here's a few of the
lines.

Workbooks.Open Filename:= _
"C:\Documents and Settings\Administrator\My
Documents\CustomSafety\010184641.xls"
Range("A11:B11").Select
Windows("Cust.xls").Activate
ActiveCell.Copy Sheets("CustomerList").Range("A1")
Windows("010184641.xls").Activate
ActiveSheet.Paste
Range("C11").Select
Windows("Cust.xls").Activate
Range("B6").Select
Application.CutCopyMode = False
Selection.Copy
Windows("010184641.xls").Activate
ActiveSheet.Paste

Thanks for replying.

Michele





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
Run a macro in active cell only. Want to place current date/time. time clock watcher Excel Worksheet Functions 3 July 20th 09 07:46 AM
Macro to Insert Current Date into cell - Macro to "Save As" Guy[_2_] Excel Worksheet Functions 4 December 12th 08 08:20 PM
use current cell address as beginning of macro mohavv Excel Discussion (Misc queries) 2 April 18th 08 03:52 PM
Macro to run relative to current selected cell MahD Excel Discussion (Misc queries) 3 December 11th 06 06:18 AM
Referncing the current cell name in an Excel MACRO Doug Excel Discussion (Misc queries) 1 December 8th 06 03:59 AM


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

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

About Us

"It's about Microsoft Excel"