ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Send multiple cell values to multiple cells (https://www.excelbanter.com/excel-programming/402383-send-multiple-cell-values-multiple-cells.html)

FinlandGuy

Send multiple cell values to multiple cells
 
I transfer (automaticly) data form one cell to another cell. That
other cell contains no formula or what so ever.
e.g. cell A1 is empty, and cell A1 contains the value 12345. I send
this value to cell D1 from cell A1 or any other cell. How can I do
this code for multiple cells? e.g. A1 to D1, A2 to D2, A3 to D3 ext.


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("G6")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
Application.EnableEvents = False
With Target
If .Value < "" Then
Excel.Range("A1").Value = Target.Value
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub

Thanks in Advance.

BR,
John

Mike H

Send multiple cell values to multiple cells
 
Hi,


Maybe this

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
On Error GoTo CleanUp
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then ' change to suit
Application.EnableEvents = False
Target.Offset(0, 3).Value = Target.Value
End If
CleanUp:
Application.EnableEvents = True
End Sub

Mike

"FinlandGuy" wrote:

I transfer (automaticly) data form one cell to another cell. That
other cell contains no formula or what so ever.
e.g. cell A1 is empty, and cell A1 contains the value 12345. I send
this value to cell D1 from cell A1 or any other cell. How can I do
this code for multiple cells? e.g. A1 to D1, A2 to D2, A3 to D3 ext.


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("G6")) Is Nothing Then Exit Sub
On Error GoTo CleanUp
Application.EnableEvents = False
With Target
If .Value < "" Then
Excel.Range("A1").Value = Target.Value
End If
End With
CleanUp:
Application.EnableEvents = True
End Sub

Thanks in Advance.

BR,
John


FinlandGuy

Send multiple cell values to multiple cells
 
Hi,

Well I meant is they were scattered all over the sheet. Or maybe I
don't understand your code.
Because it would not work if for example. A1 to E4, A4 to G4, B3 to
F5. I hope you understand. Its hard to explain.

Thanks
BR,
John


All times are GMT +1. The time now is 08:53 PM.

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