VBA code very difficult to understand Help needed

hamadsultan

New Member
Joined
Jan 23, 2011
Messages
49
Hi Experts;
History:
I have a work book that contains 9 number of sheets but two are very important and i use excell 2007 to open it. I found some user defind function in a module which use in the Main worksheet. One of function i posted here also along with the how the programmer use in formula bar.
First code is here
Code:
Function DINTERP2(TAMB, TAMBLOW, TAMBHIGH, PWR, NX, NY, [COLOR=red]TXLOW, TYLOW[/COLOR], TXHIGH, TYHIGH, NFNC)
    Call SINTRP2(PWR, ANSLOW, NX, NY, TXLOW, TYLOW, NFNC, 1)
    Call SINTRP2(PWR, ANSHIGH, NX, NY, TXHIGH, TYHIGH, NFNC, 1)
    DINTERP2 = ANSLOW + ((TAMB - TAMBLOW) / (TAMBHIGH - TAMBLOW)) * ([COLOR=red]ANSHIGH - ANSLOW[/COLOR])
End Function
 
Sub SINTRP2(XN, ANS, NX, NY, TX, TY, NFNC, NDEG)
    NNDEG = NDEG
    If (NX > NDEG) Then GoTo LABLE2
    MsgBox "TABLE TOO SMALL FOR DESIRED DEGREE OF FIT"
    GoTo LABLEEND
LABLE2:
    If ([COLOR=red]XN < TX(1))[/COLOR] Then GoTo LABLE10
    If (XN > TX(NX)) Then GoTo LABLE20
    GoTo LABLE30
Now the programmer use it as;
Code:
=IF(C$13+DATA!F5=0,SINTERP2(E$109,81,11,FLTAMB,OPTDATA,9,1),DINTERP2(E$109,J$69,J$73,E$52,20,9,INDIRECT(J$71),INDIRECT(J$72),INDIRECT(J$75),INDIRECT(J$76),4))*F34
Now I want to undestand the following :
1.ANSLOW and ANSHIGH is used in Dinterp2 function it dfines here and use here i search all the sheets in that workbook they are only in this method. What value it used and where the values come here?
2.The code i copy from the formula bar u see INdirect(J71) and (J72) its Strings come from as J71=J70&"PWR" and same in J72.
But in the function of DINTERP2 its assign TXLOW and TYLow. When SINTRP2 call it used as TX and TY if u see programmer used TX(1) what it means?
Please help me to understand this code.
I pray to God help all the guys who help me always.
Regards
 
Sir;
I forget one thing how can i see the value of TX(1) in Local pane?
When i expand the TX in local pane it shows lot of contents but i am unable to found its value at specifiq event?

Regards
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Surely when you expand TX you can see the value of TX(1)?

or right-click TX(1) in the code, choose, Add Watch…, edit so that it reads TX(1), OK.
 
Last edited:
Upvote 0
Hi;
Thanks, I pray to God give u happines and sucess in life. I am very thankful to you to guide me.
Sir, Now i want to develop an application in VB.net and i want to use these functions in it. after some pre work i think that
1. The array used by the programmer i copied in array variable in vb.net.
2. Then copy the code as it from excell and paste into any button event.
Is it possible that same code run in VB.net?
secondly plz give me advise that can i import data into arrays from excell to the VB.net array variable?
Regards
 
Upvote 0
HI;
Thanks again. I read and write the values in a particular cell sucessfully.
but i am stuck in one place.
I create a new workbook and in which i copy the existing sheet. The old workbook as we discussed earlier have a Module i also copy and add the module into new workbook. But it is not working. How i activate it when sheet open?
Regards
 
Upvote 0
HI;
when i copy the sheet to a newworkbook sheet and press F5 i see there is no refrence. How can i copy the existing refrence to new sheet?
Regards
 
Upvote 0
hi;
As in previous post i show that when i select FLTAMB it shows a values like in a array. After copy that sheet to another sheet now it show #REF.
I have got many errors in a new sheet. How i fix it? and what is the proper procedure to copy one sheet to another with all refrences.
I used select the sheet by CTRL+A and copy it then open new workbook and paste it in SHEET 1.
Plz guide me
Regards
 
Upvote 0
HI;
Plz help. In the old sheet when i press F5 32 ref are shown how i copy them to new worksheet. i also try the name manager but there is no option for copy and cut. also in the new sheet when i try to create new the message shown its already exit. how i will solve tis problem?
Regards
 
Upvote 0
This is far too complex to deal with in a thread in a forum. From your earlier screenshots it looks like it will need a lot of sorting out. You'll probably need to consult the original author or get a programmer on site to do what you need.
 
Upvote 0
hi;
Yes; I agree but if you guys guide me step by step where i face problem i am very thankfull to you.
what it means
Main!#REF!
when i press F5 on sheet and i see the refrence name T5HP and in the name manager it refer to like Main!#REF
plz guide me thanks
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,153
Members
452,891
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top