+ Reply to Thread
Results 1 to 17 of 17

vba offset function to write one row below of reference cell

  1. #1
    Registered User
    Join Date
    11-04-2012
    Location
    İstanbul, Turkey
    MS-Off Ver
    Excel 2010
    Posts
    26

    Exclamation vba offset function to write one row below of reference cell

    Hi,

    i wrote a function,

    function Round_D (z as Variant ........)

    for example my z cell is A17 and i need to find A18.

    How can i do this with a vba offset function. Tomorrow i have a presentation, and it is mandatory to achive it.

    This far, i wrote this but, it didn't work. Please help, thank you.

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: vba offset function to write one row below of reference cell

    Hi,

    You'll need to explain why it "doesn't work" and indeed what "it" is. And what do you mean by "Find Z18"?

    Would you also change your location to something meaningful. This often helps those who respond to your requests since it tells them something about what your system locale settings might be and what your date standard might be e.g. dd/mm/yy (or if you're from the other side of the pond mm/dd/yy)
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    11-04-2012
    Location
    İstanbul, Turkey
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: vba offset function to write one row below of reference cell

    Hi Richard,

    z is a function member, i set this name for the function.

    with the function i wrote, i pass it to excel frontend to calculate some values. The only thing i couldn't solve is this problem.

    z refers to a range in excel for example A17 (or anything else). Ofcourse when i pull formula to right, it is B17, C17, D17 and goes on.

    but in the vba function i need to implicate A18, B18, C18.... so i need to use Offset function.

    There are 6 function members (x As Long, y As Variant, col1 As Integer, Col2 As Integer....) and i don' t want to expand it to 7 members.

    In my first post, i wrote this function but it didn' t work. Is it possible to write a code that implicates the cell 'one cell below the reference cell, in this case 'z' member? Thank you.


    Please Login or Register  to view this content.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: vba offset function to write one row below of reference cell

    Hi,

    I still don't understand why you say it doesn't work. It might help if you upload your workbook.

    In general Range("A1").Offset(1,0) refers to range A2 and similarly Range("A1").Cells(2,1) refers to A2.

    What is the cell ref for z in your example, what's the value in the cell immediately below it and what answer are you getting?

  5. #5
    Registered User
    Join Date
    11-04-2012
    Location
    İstanbul, Turkey
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: vba offset function to write one row below of reference cell

    Thanks so much for respond Richard,

    This is my code. In the if statement, i miss something. (If ws1.Range(z).Offset(1, 0) >= 12 Then) : I think i have to fix the code on the left.

    Not: z is linked in the "updated" sheet.

    Please Login or Register  to view this content.

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: vba offset function to write one row below of reference cell

    z As Long
    If ws1.Range(z).Offset(1, 0) >= 12 Then
    Small confusion z is declared as long then how it come referenced in range?


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  7. #7
    Registered User
    Join Date
    11-04-2012
    Location
    İstanbul, Turkey
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: vba offset function to write one row below of reference cell

    honestly, i don't know. that is why i asked for help.

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: vba offset function to write one row below of reference cell

    what is the input value of z?
    or
    which cell you would like to refer in the range (Range(z))?

  9. #9
    Registered User
    Join Date
    11-04-2012
    Location
    İstanbul, Turkey
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: vba offset function to write one row below of reference cell

    for example z is A17, i write A17 in the formula. With the "offset" in macro i want to implicate A18 to the Index_ark formula. A18 value is for example "6" so, when i am doing this function,

    Please Login or Register  to view this content.
    I want it to perceive like this;

    Please Login or Register  to view this content.
    In other words,

    Please Login or Register  to view this content.

    Thanks in advance.

  10. #10
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: vba offset function to write one row below of reference cell

    Ok try this...

    Change the z As Long to
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Mention the A17 In your Index_ark function.

  11. #11
    Registered User
    Join Date
    11-04-2012
    Location
    İstanbul, Turkey
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: vba offset function to write one row below of reference cell

    still getting an #value error.

    I have to use this formula
    Please Login or Register  to view this content.
    because, in excel, i have to expand the formula to a table (for example i'll write this function in "A19:Z200")

  12. #12
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: vba offset function to write one row below of reference cell

    #value error will occur when text value operated with numeric value like Text1+7

    Or

    when string values are added in arithmatical sign like Text1+Text2

  13. #13
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: vba offset function to write one row below of reference cell

    If ws1.Range(z).Offset(1, 0) >= 12 Then
    z = a17
    for example z is A17, i write A17 in the formula. With the "offset" in macro i want to implicate A18 to the Index_ark formula
    why not z = a18 and the code should be If ws1.Range(z) >= 12 Then?

  14. #14
    Registered User
    Join Date
    11-04-2012
    Location
    İstanbul, Turkey
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: vba offset function to write one row below of reference cell

    because, z must be linked with different colum,

    the code i' d sent is the part of the formula, not all of it.

    And in the code upside, the cell which i' ll use in "Index_ark" function must be linked to z-1 (in this case for example z: A17, z-1: A18) because the value i have to use in the "Index_ark" function is below the cell which linked to "z"

  15. #15
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: vba offset function to write one row below of reference cell

    Sorry I am unable to continue this thread... and I hope someone will help you to sortout your problem

  16. #16
    Registered User
    Join Date
    11-04-2012
    Location
    İstanbul, Turkey
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: vba offset function to write one row below of reference cell

    ok, thanks, really appreciate your attention. Hane a good day.

  17. #17
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: vba offset function to write one row below of reference cell

    Hi,

    In view of SixthSense's response, please upload your workbook as I suggested in an earlier post. I for one often find it much easier to offer a suggestion if I can see the request in the context of its workbook. However this being the Christmas holiday don't expect a response by return it may take a little longer.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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