How can i write TSR code

  • Thread starter Thread starter A-Design
  • Start date Start date
A

A-Design

Hi,
How should I write my codes that can be getting executed automatically, like
the way that excel formulas are getting executed at the back ground? Thanks,
Afshin
 
Could you please tell me what do I need to add or remove to the following
codes in order to make them like a (Event code) ? Thanks
====================================
Sub check the number()

Worksheets("Sheet1").Activate
Dim X(1 To 20) As Integer

X3 = 3
X4 = 3

For X4 = 3 To 18
If Cells(17, 13) = Cells(X4, 1) Then
Cells(17, 14) = Cells(X4, 3)
End If

'If 18 < Cells(17, 13) < 4 Then
'Cells(17, 14) = "OUT OF RANGE"
'End If

Next X4

End Sub

============================================================================
=
 
It's not what the code does, but where you put it. Event macros go in the
modules named ThisWorkbook, Sheet1, Sheet2, etc. VBA will generate the
appropriate SUB/END SUB pair depending on what you select from the list of
supported events.
 
Ok, I have changed my codes as you can see below but it doesn't work ... ,I
am so new in VBA could you please tell me how I should write the codes ?
Thanks,

Afshin
========================================
Private Sub Worksheet_Calculate()

Dim X(1 To 20) As Integer

X3 = 3
X4 = 3

For X4 = 3 To 18

If Cells(17, 13) = Cells(X4, 1) Then
Cells(17, 14) = Cells(X4, 3)
End If

Next X4

End Sub
=========================================
 
I figured it out,Thank you.


A-Design said:
Ok, I have changed my codes as you can see below but it doesn't work ... ,I
am so new in VBA could you please tell me how I should write the codes ?
Thanks,

Afshin
========================================
Private Sub Worksheet_Calculate()

Dim X(1 To 20) As Integer

X3 = 3
X4 = 3

For X4 = 3 To 18

If Cells(17, 13) = Cells(X4, 1) Then
Cells(17, 14) = Cells(X4, 3)
End If

Next X4

End Sub
=========================================
 

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

Back
Top