+ Reply to Thread
Results 1 to 3 of 3

How to use inverted comma's through macro

Hybrid View

  1. #1
    Registered User
    Join Date
    11-29-2017
    Location
    London
    MS-Off Ver
    2013
    Posts
    4

    Post How to use inverted comma's through macro

    Hi there

    I have a question regarding how to send inverted commas "" through macro

    I have below formula which is working fine in Excel

    =IF(LEN(A4)=4,"00"&A4,IF(LEN(A4)=5,"0"&A4,IF(LEN(A4)=6,""&A4)))

    but now i want to send this through a command through macro like below

    ActiveCell.Formula = =IF(LEN(A4)=4,"00"&A4,IF(LEN(A4)=5,"0"&A4,IF(LEN(A4)=6,""&A4)))


    I have tried below solution but its not working.

    "=IF(LEN(A4)=4,Char(34)&00&Char(34)&A4,IF(LEN(A4)=5,Char(34)&0&Char(34)&A4,IF(LEN(A4)=6,Char(34)&Char (34)&A4)))"

    Any help highly appreciated.

    Thanks

    Khawar

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: How to use inverted comma's through macro

    welcome to the forum. try:
    ActiveCell.Formula = "=IF(LEN(A4)=4,""00""&A4,IF(LEN(A4)=5,""0""&A4,IF(LEN(A4)=6,""""&A4)))"

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: How to use inverted comma's through macro

    Hi,

    You can simply double the quotes that are inside the formula string
    ActiveCell.Formula = "=IF(LEN(A4)=4,""00""&A4,IF(LEN(A4)=5,""0""&A4,IF(LEN(A4)=6,""""&A4)))"
    or use a simpler formula
    ActiveCell.Formula = "=RIGHT(""000000""&A4,6)"
    Don
    Please remember to mark your thread 'Solved' when appropriate.

+ 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. How to create an inverted array
    By XLalbania in forum Excel General
    Replies: 8
    Last Post: 09-25-2016, 06:49 AM
  2. Help me sort this code layout error! Missing inverted comma!
    By ropbasuel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2013, 12:31 AM
  3. charts - inverted triangle.
    By nickboyuk in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-12-2006, 10:56 AM
  4. [SOLVED] solve a inverted matrix
    By Angelo in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-11-2006, 12:55 AM
  5. can text be inverted by 180deg
    By tryer in forum Excel General
    Replies: 2
    Last Post: 08-28-2005, 08:05 AM
  6. Graph on Inverted Scale
    By Deepak Thakkar in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-26-2005, 03:04 AM

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