#1   Report Post  
DrJBN
 
Posts: n/a
Default Switching cells

Is there a macro out there where I can select array 1 and array 2 and switch
their contents without having to copy/cut/past array 2 to array 3, array 1 to
array 2, and then array 3 to array 1?

Thanks,
Byron
--
Unsophisticated User
  #2   Report Post  
Jim Rech
 
Posts: n/a
Default

No. If you replace item 1 with item 2 (item = cell or array element) then
item 1 no longer exists unless you preserved it first.

--
Jim
"DrJBN" wrote in message
...
Is there a macro out there where I can select array 1 and array 2 and
switch
their contents without having to copy/cut/past array 2 to array 3, array 1
to
array 2, and then array 3 to array 1?

Thanks,
Byron
--
Unsophisticated User



  #3   Report Post  
DrJBN
 
Posts: n/a
Default

Yes, I understand this, but I had hoped that a macro existed (i.e,. one
someone had written) that would take care of all the copying, cutting, and
pasting to and from the third array to preserve the list being overwritten.
Thanks for the reply.
--
Unsophisticated User


"Jim Rech" wrote:

No. If you replace item 1 with item 2 (item = cell or array element) then
item 1 no longer exists unless you preserved it first.

--
Jim
"DrJBN" wrote in message
...
Is there a macro out there where I can select array 1 and array 2 and
switch
their contents without having to copy/cut/past array 2 to array 3, array 1
to
array 2, and then array 3 to array 1?

Thanks,
Byron
--
Unsophisticated User




  #4   Report Post  
Gord Dibben
 
Posts: n/a
Default

JBN

Code from the late and sorely missed Frank Kabel.

Hi
this would<be only possible with VBA (using an event procedure). Not
possible with formulas.

For your example put the following code in your worksheet module (not
in a standard module). To get into the worksheet module right-click on
the tab name and choose 'Code'

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A:B")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
application.enableevents = false
With Target
if .value <"" then
select case .column
case 1
.offset(0,1).value = .value
case 2
.offset(0,-1).value = .value
end select
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub



Gord Dibben Excel MVP

On Tue, 3 May 2005 11:32:05 -0700, "DrJBN"
wrote:

Yes, I understand this, but I had hoped that a macro existed (i.e,. one
someone had written) that would take care of all the copying, cutting, and
pasting to and from the third array to preserve the list being overwritten.
Thanks for the reply.


  #5   Report Post  
DrJBN
 
Posts: n/a
Default

Thanks for the code!
--
Unsophisticated User


"Gord Dibben" wrote:

JBN

Code from the late and sorely missed Frank Kabel.

Hi
this would<be only possible with VBA (using an event procedure). Not
possible with formulas.

For your example put the following code in your worksheet module (not
in a standard module). To get into the worksheet module right-click on
the tab name and choose 'Code'

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A:B")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
application.enableevents = false
With Target
if .value <"" then
select case .column
case 1
.offset(0,1).value = .value
case 2
.offset(0,-1).value = .value
end select
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub



Gord Dibben Excel MVP

On Tue, 3 May 2005 11:32:05 -0700, "DrJBN"
wrote:

Yes, I understand this, but I had hoped that a macro existed (i.e,. one
someone had written) that would take care of all the copying, cutting, and
pasting to and from the third array to preserve the list being overwritten.
Thanks for the reply.





  #6   Report Post  
Gord Dibben
 
Posts: n/a
Default

Thanks for the feedback.

Frank's legacy carries on.


Gord

On Fri, 6 May 2005 07:41:17 -0700, "DrJBN"
wrote:

Thanks for the code!


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
Help adding text values Texas-DC_271 Excel Worksheet Functions 7 January 15th 05 11:14 PM
Convert data type of cells to Text,Number,Date and Time Kevin Excel Worksheet Functions 1 December 31st 04 12:57 PM
To safety merge cells without data destroyed, and smart unmerge! Kevin Excel Discussion (Misc queries) 0 December 30th 04 07:17 AM
Heps to design Locked/Unlocked cells in protected worksheet Kevin Excel Discussion (Misc queries) 0 December 30th 04 07:09 AM
Convert data of cells to any type: Number, Date&Time, Text Kevin Excel Discussion (Misc queries) 0 December 30th 04 06:55 AM


All times are GMT +1. The time now is 07:48 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"