+ Reply to Thread
Results 1 to 11 of 11

Converting formula to VBA code

  1. #1
    Registered User
    Join Date
    11-17-2010
    Location
    India
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    83

    Converting formula to VBA code

    Friends,

    I need your help to convert a simple formula to VBA code to reflect data of cell Y1 in cell F1.

    Formula is
    Please Login or Register  to view this content.
    . Can it be done using VBA code.

    Really i need your help to do it.

    Please assist.

    Thanks Saky

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Converting formula to VBA code

    You can always record a macro to get the code for things like this:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-17-2010
    Location
    India
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    83

    Re: Converting formula to VBA code

    Friend,

    Thanks for your response. But if i record a macro and run it works fine.

    But for ex i am giving range from F1 to F100 then if i run the macro it pulls data till F100. But if there is no data in Y100 then F1 shows as 0. That is where the problem.

    Thats y i dont prefer record macro... Can it be done using worksheet change event???

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Converting formula to VBA code

    This maybe? Not sure I follow you.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-17-2010
    Location
    India
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    83

    Re: Converting formula to VBA code

    I found a VBA code for the same
    Please Login or Register  to view this content.
    it works fine but the problem is the data is reflecting in column F only if any action is performed in column Y. But the datas in column Y is automatically getting calculated by a formula. So is there any changes that can be made to this code to work??

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Converting formula to VBA code

    Why do you need this? What are you going to do with the code?

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  7. #7
    Registered User
    Join Date
    11-17-2010
    Location
    India
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    83

    Re: Converting formula to VBA code

    I am preparing a report excel for my team. do you want me to detaily explain about my project?

    If you need tell me i will explain you.

    Even the above code works as the same...can you help me with FOR loop codings so i believe every time when i run the macro the formula will get pasted one by one. first click the formula will be in first cell and in the second click it will come to the next cell...is it possible??

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Converting formula to VBA code

    IThe code that posted puts the formula into F1:F100, not displaying zeros. Your code looks like it should be in the WorkSheet_Change event

  9. #9
    Registered User
    Join Date
    11-17-2010
    Location
    India
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    83

    Re: Converting formula to VBA code

    Yes it is in worksheet change event. It works fine but the column F reflects data only when any action is performed in column Y. But i want the column F to be automatically populated once the data is populated in column Y.

    Column Y consists of formula like
    Please Login or Register  to view this content.
    . so it will automatically calculate the date once the column i and x is filled. But i need the date to be refelected in column F once the column Y is populated.

    Can it be done???

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Converting formula to VBA code

    Is this what you mean

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    11-17-2010
    Location
    India
    MS-Off Ver
    Microsoft Office Excel 2003
    Posts
    83

    Re: Converting formula to VBA code

    Roy, Thanks this what i exactly expecting. This code works fine but if you see this code works fine but the Cell F1 is reflecting the data only when i go and click or press F2 in cell Y1. So it requires some trigger in cell Y1.

    cant it be done automatically. Because i will never click cell Y1 everytime as because it reflects the data automatically as it consists of formula
    Please Login or Register  to view this content.
    . So when I fill values in cell I1 and X1 then the value will get calculated automatically in cell Y1. so there is no manual intervention required.

    Hence i am expecting the macro to work automatically. Is it possible to do it roy?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1