#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 66
Default VB problem

I'm sure there's a way to do it, but I'm just starting to play with VB and I
don't know too much yet about it (this discussion group being filled with
kind people who seem to enjoy puzzles, I take a chance :-)

If I select a cell or range within column D, for every EMPTY cell of the
selected range whose equivalent in row M is a NUMBER, I want the number in
question to be copied over to the empty cell.

I'd like to kindly thank any who will spend even fruitless time on this
problem and to apologize to whoever might have conceived frustration at me
while doing so.

Feelu
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,069
Default VB problem

Put this SelectionChange event code in the code page for the worksheet where
you want this to work:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim c As Range
If Intersect(Target, Columns("D")) Is Nothing Then Exit Sub
For Each c In Target
If Len(c.Value) = 0 And IsNumeric(c.Offset(0, 9)) Then
c.Value = c.Offset(0, 9).Value
End If
Next c
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Hope this helps,

Hutch

"FiluDlidu" wrote:

I'm sure there's a way to do it, but I'm just starting to play with VB and I
don't know too much yet about it (this discussion group being filled with
kind people who seem to enjoy puzzles, I take a chance :-)

If I select a cell or range within column D, for every EMPTY cell of the
selected range whose equivalent in row M is a NUMBER, I want the number in
question to be copied over to the empty cell.

I'd like to kindly thank any who will spend even fruitless time on this
problem and to apologize to whoever might have conceived frustration at me
while doing so.

Feelu

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 66
Default VB problem

That worked just like a charm.

Thanks for taking the time to answer and also for the link you provided in
your message. That was very kind.

Feelu

"Tom Hutchins" wrote:

Put this SelectionChange event code in the code page for the worksheet where
you want this to work:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim c As Range
If Intersect(Target, Columns("D")) Is Nothing Then Exit Sub
For Each c In Target
If Len(c.Value) = 0 And IsNumeric(c.Offset(0, 9)) Then
c.Value = c.Offset(0, 9).Value
End If
Next c
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Hope this helps,

Hutch

"FiluDlidu" wrote:

I'm sure there's a way to do it, but I'm just starting to play with VB and I
don't know too much yet about it (this discussion group being filled with
kind people who seem to enjoy puzzles, I take a chance :-)

If I select a cell or range within column D, for every EMPTY cell of the
selected range whose equivalent in row M is a NUMBER, I want the number in
question to be copied over to the empty cell.

I'd like to kindly thank any who will spend even fruitless time on this
problem and to apologize to whoever might have conceived frustration at me
while doing so.

Feelu

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
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
problem with a conditional max problem Brian Cornejo Excel Discussion (Misc queries) 1 February 18th 05 06:25 PM


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