Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Run Macro from cell change THEN select adjacent cell

FIRST, thanks in advance to All that respond...

In this spreadsheet, I have text in B2:B30. I would like to run a macro
once I edit one of the cells - the Macro is a randomizer formula, in which I
would like the result to land into F2:F30.

EXAMPLE

If I edit B7, once i get out of that cell, I would want the randomizer
result to land in F7...not the entire range.

Hopefully that makes sense...I have limited knowledge of VB, but am playing
with it
Cheers

  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Run Macro from cell change THEN select adjacent cell

Right click on your sheet tab and select view code. Then paste this macro
into the code sheet that appears.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B2:B30")) Is Nothing Then
Target(1, 5).Value = "Randomizer"
End If
Application.EnableEvents = True
End Sub


You will need to put your code to calculate your "Randomizer" value inside
of the IF statement. Right now, I just assign the word "Randomizer" to the
corresponding cell in column F.



"mslabbe" wrote:

FIRST, thanks in advance to All that respond...

In this spreadsheet, I have text in B2:B30. I would like to run a macro
once I edit one of the cells - the Macro is a randomizer formula, in which I
would like the result to land into F2:F30.

EXAMPLE

If I edit B7, once i get out of that cell, I would want the randomizer
result to land in F7...not the entire range.

Hopefully that makes sense...I have limited knowledge of VB, but am playing
with it
Cheers

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default Run Macro from cell change THEN select adjacent cell

Maybe something like this:

Private Sub Worksheet_Change(ByVal Target As Range)
If Union(Target, Range("B2:B30")).Address = "$B$2:$B$30" Then
Target.Offset(0, 4).Value = Rnd()
End If
End Sub

This would go in the code module for the sheet in question. Just
replace "Rnd()" by your VBA formula or function.

Hope that helps

-John Coleman

mslabbe wrote:
FIRST, thanks in advance to All that respond...

In this spreadsheet, I have text in B2:B30. I would like to run a macro
once I edit one of the cells - the Macro is a randomizer formula, in which I
would like the result to land into F2:F30.

EXAMPLE

If I edit B7, once i get out of that cell, I would want the randomizer
result to land in F7...not the entire range.

Hopefully that makes sense...I have limited knowledge of VB, but am playing
with it
Cheers


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Run Macro from cell change THEN select adjacent cell

That works perfectly!!!
Thanks

"JMB" wrote:

Right click on your sheet tab and select view code. Then paste this macro
into the code sheet that appears.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B2:B30")) Is Nothing Then
Target(1, 5).Value = "Randomizer"
End If
Application.EnableEvents = True
End Sub


You will need to put your code to calculate your "Randomizer" value inside
of the IF statement. Right now, I just assign the word "Randomizer" to the
corresponding cell in column F.



"mslabbe" wrote:

FIRST, thanks in advance to All that respond...

In this spreadsheet, I have text in B2:B30. I would like to run a macro
once I edit one of the cells - the Macro is a randomizer formula, in which I
would like the result to land into F2:F30.

EXAMPLE

If I edit B7, once i get out of that cell, I would want the randomizer
result to land in F7...not the entire range.

Hopefully that makes sense...I have limited knowledge of VB, but am playing
with it
Cheers

  #5   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Run Macro from cell change THEN select adjacent cell

You are welcome.

"mslabbe" wrote:

That works perfectly!!!
Thanks

"JMB" wrote:

Right click on your sheet tab and select view code. Then paste this macro
into the code sheet that appears.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B2:B30")) Is Nothing Then
Target(1, 5).Value = "Randomizer"
End If
Application.EnableEvents = True
End Sub


You will need to put your code to calculate your "Randomizer" value inside
of the IF statement. Right now, I just assign the word "Randomizer" to the
corresponding cell in column F.



"mslabbe" wrote:

FIRST, thanks in advance to All that respond...

In this spreadsheet, I have text in B2:B30. I would like to run a macro
once I edit one of the cells - the Macro is a randomizer formula, in which I
would like the result to land into F2:F30.

EXAMPLE

If I edit B7, once i get out of that cell, I would want the randomizer
result to land in F7...not the entire range.

Hopefully that makes sense...I have limited knowledge of VB, but am playing
with it
Cheers

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
Inputting cell value from source cell based on value in adjacent cell. michaelberrier Excel Discussion (Misc queries) 3 December 9th 06 09:16 PM
change current cell colour based on the value of adjacent cell on other worksheet Rits Excel Programming 2 November 23rd 06 11:57 AM
How do I Select Multiple Non Adjacent Rows based on a cell value? avalynch Excel Worksheet Functions 2 October 1st 06 07:45 PM
select cell value based on value in adjacent cell Paige Excel Worksheet Functions 2 April 26th 06 07:54 PM
How to change row color when select a cell in this row? Amolin Excel Programming 3 April 17th 04 12:11 PM


All times are GMT +1. The time now is 02:49 AM.

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"