Help needed for xml data to VBA

Lucky0683

New Member
Joined
Jun 28, 2018
Messages
4
Hi,

I need quite a bit of help here as I am new to VBA and XML. I have an Infopath form that basically stores data that users fill in in XML format. Then it will be passed to the Excel to treat the data.

There are some data that will be repeated throughout the Infopath form, e.g. Name, Dates etc. However, there will be data that will require users to keep inputting as it is unique to each transaction e.g. Price, Currency etc.

As such, the previous code should allow for those data that are repeated to continue working as per normal (kindly advise me if this is not true), but I would have to tweak the codes to allow excel to run the data that users have to keep inputting. The data that is unique to each transaction will now be renamed as 'Price1', 'Price2'....

So basically, I would need the repeated data to stay in the excel throughout as the added data changes (e.g. Price1, Currency1 etc gets added to the table) and is saved into the Database before looping on to the next Price2 etc... If there isn't anymore, then the code should stop running so that it does not take up so much time.

What I have so far is this:

Sub sub_inputData(dicData As Dictionary)


Dim ws As Worksheet: Set ws = ActiveSheet

Dim i As Integer
Dim j As Integer

Dim vTemp As Variant
Range("rInputStart").Parent.Calculate
vTemp = Range(Range("rInputStart").Offset(1), Range("rInputStart").End(xlDown).Offset(0, 2)).value

ReDim price(j) As Long

Dim currency As String: currency = vbNullString
Dim exchangeRate as string: exchangeRate = vbNullString
Dim remark as string: remark = vbNullString

For j = 1 To 10

price(j) = Range("rPriceManual").value --> and at this point, other functions will be called to convert the prices to different currencies etc, as long as the prices are inserted into the table correctly
currency = currency & dicData("dl_currency" & CStr(j)) & "|"
exchangeRate = (exchangeRate & dicData("exchange_rate" & CStr(j)) & "|") / 100
Remark = remark & dicData("remarks" & CStr(j)) & "|"

For i = LBound(vTemp, 1) To UBound(vTemp, 1)
If vTemp(i, 1) = "currency" And dicData(dl_currency) <> vbNullString Then
vTemp(i, 3) = currency
If vTemp(i, 2) = "remark" Then
vTemp(i, 3) = Remark
End If
If vTemp(i, 2) = "exchangeRate" Then
vTemp(i, 3) = exchangeRate
End If
Next i
Next j


End Sub

It does not work properly and I'm not sure whether im doing the best and most efficient way.Please kindly assist me in this as I am really lost at this. Thank you in advance!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top