Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Copy and Paste using VBA.

Hi,

If A1 is not blank then Copy A1 and Paste in A2:A7.

I originally had simple links in cells A2:A7 that connected to A1. But
sometimes one of the cells in range A2:A7 may manually have a value typed in
them, which erases the link to A1.

I thought trying this using VBA would eliminate the cell linkage loss.

I'm new to VBA.

Any suggestions would be appreciated.
Amy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Copy and Paste using VBA.

Right-click the tab for the sheet where you want this to apply, select "View
Code", then paste in the code below. If you really want it to behave the
same as a link, then I'd take out the part about range("a1") < "" (including
the underscore character and the line break before "Then"). That way,
whatever is in A1 will always be in A2:A7.

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("A1")) Is Nothing _
And Range("A1") < "" Then
Range("A2:A7").Value = Range("A1").Value
End If

End Sub


"spreadsheetlady" wrote:

Hi,

If A1 is not blank then Copy A1 and Paste in A2:A7.

I originally had simple links in cells A2:A7 that connected to A1. But
sometimes one of the cells in range A2:A7 may manually have a value typed in
them, which erases the link to A1.

I thought trying this using VBA would eliminate the cell linkage loss.

I'm new to VBA.

Any suggestions would be appreciated.
Amy

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Copy and Paste using VBA.

Thank-you B Lynn B. It works perfectly and is exactly what I wanted.
Amy



"B Lynn B" wrote:

Right-click the tab for the sheet where you want this to apply, select "View
Code", then paste in the code below. If you really want it to behave the
same as a link, then I'd take out the part about range("a1") < "" (including
the underscore character and the line break before "Then"). That way,
whatever is in A1 will always be in A2:A7.

Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("A1")) Is Nothing _
And Range("A1") < "" Then
Range("A2:A7").Value = Range("A1").Value
End If

End Sub


"spreadsheetlady" wrote:

Hi,

If A1 is not blank then Copy A1 and Paste in A2:A7.

I originally had simple links in cells A2:A7 that connected to A1. But
sometimes one of the cells in range A2:A7 may manually have a value typed in
them, which erases the link to A1.

I thought trying this using VBA would eliminate the cell linkage loss.

I'm new to VBA.

Any suggestions would be appreciated.
Amy

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
Can't Copy and Paste or Paste Special between Excel Workbooks wllee Excel Discussion (Misc queries) 5 April 29th 23 03:43 AM
Automating copy/paste/paste special when row references change Carl LaFong Excel Programming 4 October 8th 07 06:10 AM
help w/ generic copy & paste/paste special routine DavidH[_2_] Excel Programming 5 January 23rd 06 03:58 AM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM


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

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"