VB problem

F

FiluDlidu

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
 
T

Tom Hutchins

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
 
F

FiluDlidu

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top