How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask The-PC-Guy Your Own Question
The-PC-Guy
The-PC-Guy, Computer Manager
Category: Microsoft Office
Satisfied Customers: 2010
Experience:  20 years experience providing remote computer support
62934938
Type Your Microsoft Office Question Here...
The-PC-Guy is online now
A new question is answered every 9 seconds

Hi, My VBA skills arent great, so bear with me. I have

This answer was rated:

Hi,

My VBA skills aren't great, so bear with me. I have some code pre-provided which brings in data from an API, which I need VBA to display on the worksheet, and split. It is comma delimited data, and it just needs to be displayed in cell H6 of this sheet, and split using the comma as the delimiter.

The pre-provided code is this:



------------------------

Dim buf As String * 16384

Dim stat As Integer
Dim blen As Integer

blen = 16384

stat = GetRace(buf, blen, CDBDE_REFCODE_TABLIMITED, "MR", "1", CDBDE_STATE_TABCORP, CDBDE_POOL_WIN, 10, 0)

If stat CDBDE_COMMAND_COMPLETED Then
MsgBox "An error occurred accessing the Engine, re-initialize"
Else

MsgBox buf

End If
------------------

As you can see, it resolves with a msgbox of the data, when what I really want it to do is display it in cell h6, comma delimited values.

No doubt it's very simple for you guys but as I stated, my programming is limited!!

Thanks for your help
Hi, welcome and thank you for your question. My name is XXXXX XXXXX I am glad to assist you today.

Can you send me the copy of the Excel file so that I can test it directly on the file itself? If this is possible, you can upload the file to http://wikisend.com and then give me the download link or the 6-digit File ID.


Please let me know so that I can help you further.

Best regards,
Jess
Customer: replied 3 years ago.


Hi Jess,


 


Sending you the file won't be of any use, because you won't have the data from the API to display, you'll get an error message without the API.

Cameron,

No problem. Please tell me the name of the sheet where cell H6 is. Is it named sheet1? Please use this code after the ELSE line at the bottom:

Else

Sheet1.Cells.Range("H6").Text = buf

End If

In this case, replace Sheet1 with the actual name of the sheet where H6 resides.

Please remember to rate my service positively (3-5 stars/faces) once you have all the information you need. Tips are always highly appreciated! Cool

If you have any other questions, please do not rate me negatively. Instead, please ask me or reply to me – I’ll be happy to respond.

Thank you!

Best regards,
Jess
Customer: replied 3 years ago.


Using that code in place of the msgbox code comes up with an error,


 


Run-time error 424:


 


Object required

Cameron,

Can you send a copy of the Excel file? I need to know the structure of the entire code. I can just bypass the API connection and results, I just need to test your BUF variable to be displayed on the H6 cell.

Jess
Thanks for using JustAnswer. My name isXXXXX will do whatever I can to answer your question

the correct syntax is

ActiveSheet.Cells.Range("H6").Value = buf

let me know if you need anything else
Customer: replied 3 years ago.
here is the modified version.

http://wikisend.com/download/281296/testexcel.xlsm


I can't test.

But assuming your api is setting the buf variable to exactly what you want. Then this modified code puts that value in H6 instead of msgbox
Customer: replied 3 years ago.


OK, that's getting there, at least the data is in the cell now, there's just one final part: it needs to be parsed into rows and columns. I've resent the file back with the info in H6, but that info essentially needs to be parsed into a table, or array, separated by it's rows (ie lines) and by the columns, which are comma delimited. I am sure that's easily done in the code also??


 


The updated file is here -


 


http://wikisend.com/download/504048/testexcel.xlsm


 

ok, its late where I am, will take a look at it tomorrow.
havent been able to test this yet.

But it should do what you want now.

http://wikisend.com/download/313962/testexcel.xlsm


Cool PLEASE REMEMBER TO RATE MY SERVICE SO I GET COMPENSATED FOR MY TIME: Cool

you may do so with the smiley faces underneath this chat window
The-PC-Guy, Computer Manager
Category: Microsoft Office
Satisfied Customers: 2010
Experience: 20 years experience providing remote computer support
The-PC-Guy and 3 other Microsoft Office Specialists are ready to help you
Customer: replied 3 years ago.

That produced an error... but don't worry, I have managed to work it out with the help of someone else in the meantime.

ok.

Sorry Since I didn't have the api functions I couldn't test it.

if you need anything else let me know

Cool PLEASE REMEMBER TO RATE MY SERVICE SO I GET COMPENSATED FOR MY TIME: Cool