ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Sending data from one cell to another (https://www.excelbanter.com/excel-discussion-misc-queries/223247-sending-data-one-cell-another.html)

Maria

Sending data from one cell to another
 
Sorry if this is posted twice-

I would like to have data from one cell get sent to another cell in the same
worksheet. But I don't want to put a formula in the second cell to grab that
data from the first cell. Is this possible?

For example, if I type in my first name in A1, I would like it to
automatically appear in cells A2, A3, and A4. However, I would like to have
the flexibility to type in my last name into A3 and have that then
automatically appear in A4 as well.

Thanks for your time,
Maria




Gary''s Student

Sending data from one cell to another
 
Insert this event macro in the worksheet code area:

rivate Sub Worksheet_Change(ByVal Target As Range)
Dim A1 As Range, A3 As Range, A4 As Range
Dim t As Range, A24 As Range
Set A1 = Range("A1")
Set A3 = Range("A3")
Set A4 = Range("A4")
Set A24 = Range("A2:A4")
Set t = Target
If Intersect(t, Union(A1, A3)) Is Nothing Then Exit Sub
Application.EnableEvents = False
If Intersect(t, A3) Is Nothing Then
A1.Copy A24
Else
A3.Copy A4
End If
Application.EnableEvents = True
End Sub


Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm

To learn more about Event Macros (worksheet code), see:

http://www.mvps.org/dmcritchie/excel/event.htm


--
Gary''s Student - gsnu200836


"Maria" wrote:

Sorry if this is posted twice-

I would like to have data from one cell get sent to another cell in the same
worksheet. But I don't want to put a formula in the second cell to grab that
data from the first cell. Is this possible?

For example, if I type in my first name in A1, I would like it to
automatically appear in cells A2, A3, and A4. However, I would like to have
the flexibility to type in my last name into A3 and have that then
automatically appear in A4 as well.

Thanks for your time,
Maria




Gord Dibben

Sending data from one cell to another
 
Formulas cannot "send" data anywhere.

In A2, A3 and A4 you must have formulas linking to A1 by =A1

But if you overwrite the formula in A3, it no longer is a formula and A4 is
still linked to A1 so can't return what you typed in A3

What you want to occur can only be done through VBA code


Gord Dibben MS Excel MVP

On Thu, 5 Mar 2009 11:51:02 -0800, Maria
wrote:

Sorry if this is posted twice-

I would like to have data from one cell get sent to another cell in the same
worksheet. But I don't want to put a formula in the second cell to grab that
data from the first cell. Is this possible?

For example, if I type in my first name in A1, I would like it to
automatically appear in cells A2, A3, and A4. However, I would like to have
the flexibility to type in my last name into A3 and have that then
automatically appear in A4 as well.

Thanks for your time,
Maria





All times are GMT +1. The time now is 05:44 AM.

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