+ Reply to Thread
Results 1 to 10 of 10

Removing and Adding Characters from Strings in VBA + add and open this to a Sharepoint URL

  1. #1
    Registered User
    Join Date
    05-19-2021
    Location
    Netherlands
    MS-Off Ver
    Version 2104
    Posts
    33

    Question Removing and Adding Characters from Strings in VBA + add and open this to a Sharepoint URL

    I have an Excel sheet attached where I have a column called "Numbers"

    The next column called "Button" needs a VBA code where it does the following: Remove ABC from the "Numbers" and in case of a -1 or -2 also remove this + add the number 100.
    So ABC123456 becomes 100123456 and ABC123456-1 also becomes 100123456

    I did manage to get a VBA output in the column "Button" where it just removes ABC using something
    Please Login or Register  to view this content.
    But I struggle to create one meeting all 3 requirements.


    Once this output in the column "Button" has been established I want to use this same cell for the following function (button)

    Please Login or Register  to view this content.
    But on cell activation it needs to open the URL google.com but with the "Button" cell added after a /
    So on cell activation it needs to open the following URL: google.com/100123456
    Attached Files Attached Files
    Last edited by Nebucanezars; 10-27-2022 at 07:45 AM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,192

    Re: Removing and Adding Characters from Strings in VBA + add and open this to a Sharepoint

    Try

    =[@Url]&"/100" & SUBSTITUTE(SUBSTITUTE(SUBSTITUTE([@Numbers],"ABC",""),"-1",""),"-2","")
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Registered User
    Join Date
    05-19-2021
    Location
    Netherlands
    MS-Off Ver
    Version 2104
    Posts
    33

    Re: Removing and Adding Characters from Strings in VBA + add and open this to a Sharepoint

    Thanks a lot JohnTopley, your help is much appreciated.
    The output is correct!

    I have two questions left for my problem which I cant seem to figure out.

    Is it possible to translate this formula into a VBA string which works for a selected column range instead of inserting this in seperate cells in the sheet itself?

    Also how do I create a hyperlink from the cells output? I cant figure out how to do this with a cell containing a formula.

  4. #4
    Registered User
    Join Date
    05-19-2021
    Location
    Netherlands
    MS-Off Ver
    Version 2104
    Posts
    33

    Re: Removing and Adding Characters from Strings in VBA + add and open this to a Sharepoint

    I have inserted a file with the data in column A and the button in Collumn B

    The VBA Code is added under the VBA Application / Excel Objects / Sheet1

    I have been trying for a week and figure out how I am able to get the follow code to work but it doesn't

    On cell activation in collumn B it needs to run the following Macro: ("https://google.com" & "/100" & Substitute(Substitute(Substitute(Substitute(Substitute(A2, "ABC", ""), "-1", ""), "-2", ""), "-3", ""), "-4", ""))

    Please Login or Register  to view this content.
    Is there anyone who could point me in the right direction with this issue?
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,192

    Re: Removing and Adding Characters from Strings in VBA + add and open this to a Sharepoint

    This ??

    Please Login or Register  to view this content.
    "Replace" not "Substitute" in VBA
    Last edited by JohnTopley; 11-11-2022 at 06:16 AM.

  6. #6
    Registered User
    Join Date
    05-19-2021
    Location
    Netherlands
    MS-Off Ver
    Version 2104
    Posts
    33

    Re: Removing and Adding Characters from Strings in VBA + add and open this to a Sharepoint

    I am getting closer!

    I am using the following code now

    Please Login or Register  to view this content.
    When I click the button the cell is showing the right output but there is no Hyperlink output.

    The last thing which is needed is to add something to the VBA code that opens the hyperlink output upon click and activating the above VBA code
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Removing and Adding Characters from Strings in VBA + add and open this to a Sharepoint

    try
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    05-19-2021
    Location
    Netherlands
    MS-Off Ver
    Version 2104
    Posts
    33

    Re: Removing and Adding Characters from Strings in VBA + add and open this to a Sharepoint

    The code provided in the latest reply also does the trick by creating the right output upon activating the cell (see latest excel file attachment)

    Please Login or Register  to view this content.
    I have been reading a lot and trying to solve the last step in my problem which is the following.
    After selecting the cell and creating the right output it also needs to open this output in the default browser.

    I tried to add the following code on top of the code as above
    But I havent been able to get it to work.

    Please Login or Register  to view this content.
    Is there anyone who can point me in the right direction?
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Removing and Adding Characters from Strings in VBA + add and open this to a Sharepoint

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    05-19-2021
    Location
    Netherlands
    MS-Off Ver
    Version 2104
    Posts
    33

    Re: Removing and Adding Characters from Strings in VBA + add and open this to a Sharepoint

    Thanks for all the help, much appreciated.

    Final code that solved my problem:

    Please Login or Register  to view this content.

+ 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] Adding and Removing Characters in a Cell
    By Dr.Acula in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-27-2022, 10:22 PM
  2. Filepath on SharePoint drive - more than 256 characters allowed
    By lb_33 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-02-2022, 08:53 AM
  3. Removing Quotes from Strings
    By muddbog in forum Excel General
    Replies: 4
    Last Post: 05-23-2014, 03:28 AM
  4. [SOLVED] Adding characters to raw data text strings
    By nighthalcyon in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-07-2013, 10:02 AM
  5. Removing Duplicates and adding special characters
    By dawsonsoo in forum Excel General
    Replies: 7
    Last Post: 10-12-2011, 02:49 PM
  6. Help with removing certain strings from cells
    By sparkroms in forum Excel General
    Replies: 2
    Last Post: 07-25-2006, 01:20 AM
  7. [SOLVED] characters and strings
    By elicamacho in forum Excel General
    Replies: 4
    Last Post: 03-20-2006, 02:25 PM

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