Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Newbie needs help in VBA ;creating a click() function

Hi all
This is my 1st post.I am really new in VBA . Need help from all.

code:

Option Base 1
Function ABN(n, npoint)
Dim Temp(2)
Sum = 0
sum1 = 0
alpha = 2# * 3.141592654 / npoint
For j = 1 To npoint
ang = alpha * (j - 1)
Sum = Sum + Cells(6 + j, 4) * Cos(n * ang)
sum2 = sum2 + Cells(6 + j, 4) * Sin(n * ang)
Next j
Temp(1) = Sum * 2# / npoint
Temp(2) = sum2 * 2# / npoint
If n = 0 Then Temp(1) = Temp(1) / 2
ABN = Temp
End Function

If i wish to create a click() function such that the macro will be
activated automatically when the user click on the assigned button. The
formula will be called by the sub function.But i am not sure at all how
it should be done.

The calculated values will then appear in a created table in a
particular column.

Pls help. Urgent!. Thx


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Newbie needs help in VBA ;creating a click() function

Use the click event of teh button: Right-Click the button & then click 'View Code'. The default action for a Command Button is click, the VBE editor will open in this module

HT
Roge
Shaftesbury (UK

----- david2004 wrote: ----

Hi al
This is my 1st post.I am really new in VBA . Need help from all

code:

Option Base
Function ABN(n, npoint
Dim Temp(2
Sum =
sum1 =
alpha = 2# * 3.141592654 / npoin
For j = 1 To npoin
ang = alpha * (j - 1
Sum = Sum + Cells(6 + j, 4) * Cos(n * ang
sum2 = sum2 + Cells(6 + j, 4) * Sin(n * ang
Next
Temp(1) = Sum * 2# / npoin
Temp(2) = sum2 * 2# / npoin
If n = 0 Then Temp(1) = Temp(1) /
ABN = Tem
End Functio

If i wish to create a click() function such that the macro will b
activated automatically when the user click on the assigned button. Th
formula will be called by the sub function.But i am not sure at all ho
it should be done.

The calculated values will then appear in a created table in
particular column

Pls help. Urgent!. Th


--
Message posted from http://www.ExcelForum.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Newbie needs help in VBA ;creating a click() function

thx for replying..

Problems faced:

1) the given code is a function .. while the command button is a sub
function . I do not know how to convert into a sub function

2)Alternatively , if i need to create a sub function, how to write the
code for a summation problem:


Sum = Sum + Cells(6 + j, 4) * Cos(n * ang).

Cells(6 + j, 4) cannot be used in a subfunction.. so how should i
convert it from a function code to a sub function click().


PLs help.. thx


---
Message posted from http://www.ExcelForum.com/

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
How to stop creating an new email msg when I click on a data cell jj416 Excel Worksheet Functions 1 October 10th 06 11:13 PM
Function newbie Rubix Excel Worksheet Functions 2 November 12th 05 11:05 AM
I'm a newbie please help with my function colincannon New Users to Excel 3 August 30th 05 02:11 AM
Newbie needs a function (how sad) tjr Excel Worksheet Functions 12 January 24th 05 09:17 AM
Creating mail message with a button click Ray Proudfoot Excel Programming 8 October 2nd 03 08:36 PM


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