+ Reply to Thread
Results 1 to 4 of 4

use variable value argument for function "text"

Hybrid View

  1. #1
    Registered User
    Join Date
    07-30-2013
    Location
    Treviso
    MS-Off Ver
    Excel 2007
    Posts
    4

    Unhappy use variable value argument for function "text"

    Hello,

    I am copying text from a source worksheet (msi) to a destionation one (tabella).
    I am writing formulas on the cells of the destination wk which copy the content of
    cells in the source wk using the function "text".
    Syntax of "text" function is

    text(value, format)

    How can I give a variable cell (cell whose rox/column vary in a cycle) as first argument of function "text"?
    See lines 6 and 7 below.


    1     'write amplitude pattern
    2     
    3     Set mySh = ThisWorkbook.Worksheets("tabella")
    4     With mySh
    5         	For lRow = 0 To 59
    6         		Set rng = Range("B" & lRow + 7)
    7         		.Cells(lRow + 9, 3) = "=text(msi!rng;""#.00"")"
    8         	Next
    9     End With
    Thank you, giovanni
    Last edited by giovanni18; 08-10-2013 at 02:43 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,939

    Re: use varable value argument for function "text"

    Maybe:

    Sub test()
    'write amplitude pattern
    Set mySh = ThisWorkbook.Worksheets("tabella")
    With mySh
       For lRow = 0 To 59
           Set Rng = .Range("B" & lRow + 7)
           .Cells(lRow + 9, 3) = "=text(msi!" & Rng.Address & ";""#.00"")"
        Next
    End With
    End Sub

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    07-30-2013
    Location
    Treviso
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: use varable value argument for function "text"

    Thank you TMS!

    I just changed ";" with "," at line 7 of your snippet and the macro is now working.
    If it can be helpful for others users, line 7 becomes

    .Cells(lRow + 9, 3) = "=text(msi!" & Rng.Address & ",""#.00"")"
    thanx again, giovanni

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,939

    Re: use varable value argument for function "text"

    You're welcome.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] TEXT function - format argument to place "0" before digits
    By Maki in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-21-2013, 10:45 PM
  2. SUMIFS Function: how to make the "sum_range" argument as a non-fixed variable
    By brunocinelli in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-12-2013, 12:55 PM
  3. Replies: 9
    Last Post: 09-05-2012, 10:23 AM
  4. VBA function for "Mean" using Array as argument
    By ASokolik in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 03-28-2006, 05:15 PM
  5. text argument in vlook up which has a ""
    By carlosgdlf in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-03-2005, 08:46 AM

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