Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,388
Default VBA Question

Private Sub Worksheet_Calculate( )
Range("L" & 21 + Application.WorksheetFunction.Count([L21:L35])) = [J21].Value
End Sub

The above will not run automatically, but will run if I enter the Module and
press
the Run Sub Button.
Help please
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VBA Question

Probably because you have stored it in the wrong place. It should go in the
worksheet code module, not a standard code module.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Dave" wrote in message
...
Private Sub Worksheet_Calculate( )
Range("L" & 21 + Application.WorksheetFunction.Count([L21:L35])) =

[J21].Value
End Sub

The above will not run automatically, but will run if I enter the Module

and
press
the Run Sub Button.
Help please



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,388
Default VBA Question

Hi Bob
Thanks, it works auto now but its populating all the cells L21:L35 which I
dont
want. What it should do, if L21 is full then go to L22 and so on down to L35
every time J21 changes.
I'm stuck now not very good with VBA.


"Bob Phillips" wrote:

Probably because you have stored it in the wrong place. It should go in the
worksheet code module, not a standard code module.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Dave" wrote in message
...
Private Sub Worksheet_Calculate( )
Range("L" & 21 + Application.WorksheetFunction.Count([L21:L35])) =

[J21].Value
End Sub

The above will not run automatically, but will run if I enter the Module

and
press
the Run Sub Button.
Help please




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VBA Question

Dave,

Different event.

Remove your code and then add this

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "J21"
Dim iRow As Long

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
iRow = Me.Range("L" & Rows.Count).End(xlUp).Row + 1
If iRow < 21 Then
iRow = 21
End If
If iRow < 36 Then
Cells(iRow, "L").Value = Target.Value
End If
End If

ws_exit:
Application.EnableEvents = True
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Dave" wrote in message
...
Hi Bob
Thanks, it works auto now but its populating all the cells L21:L35 which I
dont
want. What it should do, if L21 is full then go to L22 and so on down to

L35
every time J21 changes.
I'm stuck now not very good with VBA.


"Bob Phillips" wrote:

Probably because you have stored it in the wrong place. It should go in

the
worksheet code module, not a standard code module.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Dave" wrote in message
...
Private Sub Worksheet_Calculate( )
Range("L" & 21 + Application.WorksheetFunction.Count([L21:L35])) =

[J21].Value
End Sub

The above will not run automatically, but will run if I enter the

Module
and
press
the Run Sub Button.
Help please






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
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good davegb Excel Programming 1 May 6th 05 06:35 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 27th 05 07:46 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 23 April 23rd 05 09:26 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 22nd 05 03:30 PM


All times are GMT +1. The time now is 06:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"