Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 20
Default Copy cells to neighbor column after leaving the cell

Hi -
Can anyone help me figure this out? I think I need a "With" loop, but
haven't really worked with them yet.

I have a column of empty cells. What I want to be able to do is copy
whatever is typed in any of those cells to the cell immediately to the
right of them in the column immediately to the right. I need to be
able to do this in the event (leaveCell) or whatever the event would be
called, basically as soon as the cursor leaves the cell (enter, tab,
click, whatever....) Is there a good way to do this?? Thanks a ton!
Steve

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Copy cells to neighbor column after leaving the cell

By formula...........

In B1 enter =IF(A1="","",A1)

Drag/copy down column B as far as you wish.

Event code..................

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col A
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
n = Target.Row
If Excel.Range("A" & n).Value < "" Then
Excel.Range("B" & n).Value = Excel.Range("A" & n).Value
End If
End If
enditall:
Application.EnableEvents = True
End Sub

Right-click on the sheet tab and "View Code".

Copy/paste the code into that module.


Gord Dibben MS Excel MVP

On 11 Jul 2006 07:16:17 -0700, "nemadrias" wrote:

Hi -
Can anyone help me figure this out? I think I need a "With" loop, but
haven't really worked with them yet.

I have a column of empty cells. What I want to be able to do is copy
whatever is typed in any of those cells to the cell immediately to the
right of them in the column immediately to the right. I need to be
able to do this in the event (leaveCell) or whatever the event would be
called, basically as soon as the cursor leaves the cell (enter, tab,
click, whatever....) Is there a good way to do this?? Thanks a ton!
Steve


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 20
Default Copy cells to neighbor column after leaving the cell

FANTASTIC!!! Thank you so much - the code is what I needed. Out of
curiosity can you Pseudocode the if loop for me if you have a quick
second? I don't quite understand how it works. Thanks again, keep up
the great work.
Steve


Gord Dibben wrote:
By formula...........

In B1 enter =IF(A1="","",A1)

Drag/copy down column B as far as you wish.

Event code..................

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col A
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
n = Target.Row
If Excel.Range("A" & n).Value < "" Then
Excel.Range("B" & n).Value = Excel.Range("A" & n).Value
End If
End If
enditall:
Application.EnableEvents = True
End Sub

Right-click on the sheet tab and "View Code".

Copy/paste the code into that module.


Gord Dibben MS Excel MVP

On 11 Jul 2006 07:16:17 -0700, "nemadrias" wrote:

Hi -
Can anyone help me figure this out? I think I need a "With" loop, but
haven't really worked with them yet.

I have a column of empty cells. What I want to be able to do is copy
whatever is typed in any of those cells to the cell immediately to the
right of them in the column immediately to the right. I need to be
able to do this in the event (leaveCell) or whatever the event would be
called, basically as soon as the cursor leaves the cell (enter, tab,
click, whatever....) Is there a good way to do this?? Thanks a ton!
Steve


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Copy cells to neighbor column after leaving the cell

Not sure what Pseudocode is but.........

If Target.Cells.Column =1 means column A

n =TargetRow means any row in Column A

If Excel.Range("A" & n).Value < "" means if An is not empty then stuff the
value of An into Bn as you leave An

Excel.Range("B" & n).Value = Excel.Range("A" & n).Value

.................................................. .................

=IF(A1="","",A1)

The formula method simply reads If A1 is empty, have B1 look empty also but if
A1 has a value, return that to B1


Gord

On 11 Jul 2006 08:44:54 -0700, "nemadrias" wrote:

FANTASTIC!!! Thank you so much - the code is what I needed. Out of
curiosity can you Pseudocode the if loop for me if you have a quick
second? I don't quite understand how it works. Thanks again, keep up
the great work.
Steve


Gord Dibben wrote:
By formula...........

In B1 enter =IF(A1="","",A1)

Drag/copy down column B as far as you wish.

Event code..................

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col A
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
n = Target.Row
If Excel.Range("A" & n).Value < "" Then
Excel.Range("B" & n).Value = Excel.Range("A" & n).Value
End If
End If
enditall:
Application.EnableEvents = True
End Sub

Right-click on the sheet tab and "View Code".

Copy/paste the code into that module.


Gord Dibben MS Excel MVP

On 11 Jul 2006 07:16:17 -0700, "nemadrias" wrote:

Hi -
Can anyone help me figure this out? I think I need a "With" loop, but
haven't really worked with them yet.

I have a column of empty cells. What I want to be able to do is copy
whatever is typed in any of those cells to the cell immediately to the
right of them in the column immediately to the right. I need to be
able to do this in the event (leaveCell) or whatever the event would be
called, basically as soon as the cursor leaves the cell (enter, tab,
click, whatever....) Is there a good way to do this?? Thanks a ton!
Steve


Gord Dibben MS Excel MVP
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 20
Default Copy cells to neighbor column after leaving the cell

Pseudocode is just any code in layman's terms....exactly as you did.
Thanks again for all your help.
Steve

Gord Dibben wrote:
Not sure what Pseudocode is but.........

If Target.Cells.Column =1 means column A

n =TargetRow means any row in Column A

If Excel.Range("A" & n).Value < "" means if An is not empty then stuff the
value of An into Bn as you leave An

Excel.Range("B" & n).Value = Excel.Range("A" & n).Value

.................................................. ................

=IF(A1="","",A1)

The formula method simply reads If A1 is empty, have B1 look empty also but if
A1 has a value, return that to B1


Gord

On 11 Jul 2006 08:44:54 -0700, "nemadrias" wrote:

FANTASTIC!!! Thank you so much - the code is what I needed. Out of
curiosity can you Pseudocode the if loop for me if you have a quick
second? I don't quite understand how it works. Thanks again, keep up
the great work.
Steve


Gord Dibben wrote:
By formula...........

In B1 enter =IF(A1="","",A1)

Drag/copy down column B as far as you wish.

Event code..................

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col A
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
n = Target.Row
If Excel.Range("A" & n).Value < "" Then
Excel.Range("B" & n).Value = Excel.Range("A" & n).Value
End If
End If
enditall:
Application.EnableEvents = True
End Sub

Right-click on the sheet tab and "View Code".

Copy/paste the code into that module.


Gord Dibben MS Excel MVP

On 11 Jul 2006 07:16:17 -0700, "nemadrias" wrote:

Hi -
Can anyone help me figure this out? I think I need a "With" loop, but
haven't really worked with them yet.

I have a column of empty cells. What I want to be able to do is copy
whatever is typed in any of those cells to the cell immediately to the
right of them in the column immediately to the right. I need to be
able to do this in the event (leaveCell) or whatever the event would be
called, basically as soon as the cursor leaves the cell (enter, tab,
click, whatever....) Is there a good way to do this?? Thanks a ton!
Steve


Gord Dibben MS Excel MVP


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
Copy the value of a cell, no format, into several cells. Harvey Eastman Excel Discussion (Misc queries) 3 June 30th 06 03:46 AM
Compiling macro based on cell values simonsmith Excel Discussion (Misc queries) 1 May 16th 06 08:31 PM
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 10:47 PM
I want to split containt of a cell and copy in seprate cells Sima Excel Worksheet Functions 2 May 9th 05 07:46 PM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 02:23 PM.

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"