Building a URL using Visual Basic - excel

My name is lee, and I'm new on here. I'm very experienced in Excel, and most aspects of Office, but not so much in VBA.
I have embedded a local map using an API in excel, and want to plot multiple postal codes. I have this working up to 23 postal codes using a Hyperlink and Concatenate in the same formula to build the URL. After 23 postal codes, the formula result exceeds 255 characters, so that's where I fail.
I need one solution - either a way to work around the limit (without using a 3rd party url shortener), or by building the entire URL in VBA. My button launches the formulated url from cell A1, but when it exceeds 255 characters, I assume I will need the button to run the url directly from within VBA?
Anyhow, I'm sure I've probably missed out some vital info, so please, if you think are able to help, ask me and I'll give as much extra detail as possible.

You can split the long string in lets say 2 variables and then use them in VBA to concatenate it with your formula.
An example of what you have would be better.

Related

Encoding issue in excel

As mentioned in the title I have an encoding issue in Excel. It requires special characters and also some letters.
I will show you an example: 1st being a good one and 2nd a bad one.
1st example
After I refresh the Excel workbook my special characters become something like the following.
2nd example
Sadly my work around right now is, using one of my colleagues Mac, to go in and refresh the workbook again and the special characters get fixed.
These Excel workbooks are created by a Microsoft Power Automate flow, and checking every excel file he creates in order to fix this issue, is waste of time.
Does anyone have any suggestions about how to fix this.
Sincerely, Daniel
If you are creating the Excel files yourself via a Power Automate flow you could look into using the Byte Order Mark characters to the beginning of the file.
Below is an explanation how you could achieve that:
https://powerusers.microsoft.com/t5/Building-Flows/Create-a-csv-file-that-uses-UTF-8-character-encoding/m-p/1311587/highlight/true#M148980
This is exactly what my PAD is doing. There is a master excel file, and when the online flow finds a new row in the database is running this PAD flow.
After few refreshes the new data is updated in the excel file, and that is when the special characters get changed, like presented in the main post

PowerPoint live fields, linked to Excel data

I would have thought this one would be asked to death so cannot see a solution - looking for a way to live link PowerPoint to Excel data, only for a word within an otherwise manually typed sentence.
I am not asking how to live link a chart or a table, I am asking how to have a live field within otherwise static text.
E.g. In a text box, there's the sentence "Revenue increased by 10% over the period, an improvement from the 7% increase over the prior period" and have only the '10%' and the '7%' be linked to two Excel cells.
I have seen that this is possible in the following pieces of software:
https://www.youtube.com/watch?v=mUGqgsT4gHU (skip to 20sec)
https://www.presentationpoint.com/blog/dynamic-text-boxes-powerpoint/
Doesn't seem like it's do-able in VBA though I'm comfortable in .NET too and have not been able to work out how this works, so any suggestion in either most welcome.
There are multiple suggestions to the effect of copy a cell and then paste-special - this does not allow you to embed the number in the sentence, it only allows you to past the cell in, which you would then have to type around. In the two links above, it is properly embedded and this is the type of solution I am after.
I think this is very do-able in VBA. The program on the website is of course very sophisticated, but you could very easily replicate some of the functionality.
For example by using tokens. You could enter something like "Best beer in city: #beerBrand#". Then you would iterate through your columngs and just search and replace the tokens.
If I get the program functionality right, what they do is ask the user to enter a prefix and sufix for each variable. That makes it even easier because you have the three parts of the sentence separate and you can just alsways replace the variable in the middle.
Would one of the approaches work in your case?

VBA code to extract data from website by continuing number series of data

I desperately need your help to extract data from this webpage, here I have to enter number and than it reflect the information. I want a macro that can enter value in that field and than extract data in excel.
This is the website address
http://exportefiling.fbr.gov.pk/igm/IGMview1.aspx
I will put number value in IGM field and it will show data that I need in excel, after that I will add next number in IGM field that will reflect data and that needs to be copied on excel. I need this loop to be continued to a desired number e.g. starting number is 11105 and ending value is 11200. Please help I cannot attach screen shot here.
You could try Selenium (although it is doable without). I have never used it in VBA, but it appears to be available on Github. The other way is using the COM interface (only available in Internet Explorer), but that is kind of an old fashioned solution, compared to Selenium.

Most efficient way to place hundreds of array formulas?

I am new to VBA and advanced formulas for that matter and would deeply appreciate some guidance here.
I have a workbook that acts as a GUI for a database in another workbook. I use the following array formula to act as a search function:
{=IF(ISERROR(INDEX('Client Contact Database.xlsx'!Data.ContactsFull,SMALL(IF('Client Contact Database.xlsx'!Data.ContactClients=$L$1,ROW('Client Contact Database.xlsx'!Data.ContactClients)),ROW(1:1)),2)),"",INDEX('Client Contact Database.xlsx'!Data.ContactsFull,SMALL(IF('Client Contact Database.xlsx'!Data.ContactClients=$L$1,ROW('Client Contact Database.xlsx'!Data.ContactClients)-1),ROW(1:1)),1))}
Although very sloppy, this works fine. However, I now need to add option buttons to toggle between searching for two different things. This means I have to replace the array formula from A3:L104 through VBA. My question is twofold:
How can I shorten this formula to under 255 chars to use with .FormulaArray? I tried putting it in two halves but my understanding of syntax is not sufficient.
Even if I got that to work, I imagine it would be extremely slow and inefficient. Is there a better way to go about this task?
Any help is greatly appreciated, I'm in way over my head with this. Thanks in advance.
First off, swap out your IF(ISERROR(<formula>), "", <formula>) for something that uses the IFERROR function. This will effectively cut your formula in half as IFERROR takes care of error control and default value without duplicating the formula.
=iferror(INDEX('Client Contact Database.xlsx'!Data.ContactsFull,SMALL(IF('Client Contact Database.xlsx'!Data.ContactClients=$L$1,ROW('Client Contact Database.xlsx'!Data.ContactClients)-1),ROW(1:1)),1), "")
I did not build all of the external references and named ranges for a full build environment, but I believe I transcribed that correctly.

Is there a way to access and evaluate Excel formatting codes via VBA

I am trying to write a VB script in Excel to parse some data in an Excel cell. To parse the data correctly, I need to utilize the formatting in the cell. For example, the text to be parsed below should be parsed as follows: a. MINESHAFT B. DARNLEY BAY. The only way to tell this is because MINESHAFT is displayed in a smaller font.
Is there anyway I could right a VB script that could parse the cell text based upon the hidden formatting codes in the cell.
Text to be parsed: MINESHAFT DARNLEY BAY
I'm currently trying to accomplish this in Mac 2011 Office Excel, but I could also do in on a PC Excel 2010 if it makes a difference.
Thanks for you help.
I'm sure you probably can find out the font of a section, but I think you should analyse your data to try and find another way of pulling out the information you want.
Why is the first word a different font?
Are there a finite number of MINESHAFT words?
Could you find the MINESHAFT, ETC word at the begining and put that in a, and then put the rest of the string into b?
If you post a greater amount of data you are trying to parse we might be able to help.

Resources