Macro modification
Closed
kaluputha
Posts
5
Registration date
Friday 19 February 2010
Status
Member
Last seen
2 March 2010
-
19 Feb 2010 à 09:49
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 21 Feb 2010 à 09:31
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 21 Feb 2010 à 09:31
Related:
- Macro modification
- Excel online macro - Guide
- How to run a macro in excel - Guide
- How to copy macro from one workbook to another - Guide
- Macro for number to words in excel - Guide
- Macro antena apk - Download - Gaming tools
3 responses
rizvisa1
Posts
4478
Registration date
Thursday 28 January 2010
Status
Contributor
Last seen
5 May 2022
766
19 Feb 2010 à 10:03
19 Feb 2010 à 10:03
Could you put the file at some share site
https://authentification.site
https://authentification.site
kaluputha
Posts
5
Registration date
Friday 19 February 2010
Status
Member
Last seen
2 March 2010
20 Feb 2010 à 01:38
20 Feb 2010 à 01:38
dear friends i have got the answer for second question..now i need only first question answer.pls help me....
https://authentification.site/files/21030298/test.xls
https://authentification.site/files/21030298/test.xls
rizvisa1
Posts
4478
Registration date
Thursday 28 January 2010
Status
Contributor
Last seen
5 May 2022
766
20 Feb 2010 à 10:43
20 Feb 2010 à 10:43
I am not too sure about your logic in Select_a_part_of_a_formula
How ever the issue is because of this
Call Select_a_part_of_a_formula(tmpFormula, Part1, Repeater1)
Part 1 is equal to the formula. You are doing it in the code. See the boldline
If (i > 0) Then
If (InStr(Left(Formula, i - 1), "*") > 0) Then
j = InStr(Left(Formula, i - 1), "*")
Repeater = Mid(Formula, j + 1, i - j - 1)
Part = "=" & Left(Formula, j - 1) & "*1.5"
Else
Repeater = 1
Part = "=" & Formula
End If
End If
I dont get all your reasoning. But if "+" in the formula indicates various sub formulas that you want then why not do this
change this
Private Sub Translate(OldFormula As String, _
Part1 As String, Repeater1 As Integer, _
Part2 As String, Repeater2 As Integer, _
Part3 As String, Repeater3 As Integer)
Dim tmpFormula As String, i As Integer, tmpStr As String
tmpFormula = Mid(OldFormula, 2) ' Remove "="
Call Select_a_part_of_a_formula(tmpFormula, Part1, Repeater1)
Call Select_a_part_of_a_formula(tmpFormula, Part2, Repeater2)
Call Select_a_part_of_a_formula(tmpFormula, Part3, Repeater3)
End Sub
to
Private Sub Translate(OldFormula As String, _
Part1 As String, Repeater1 As Integer, _
Part2 As String, Repeater2 As Integer, _
Part3 As String, Repeater3 As Integer)
Dim tmpFormula As String, i As Integer, tmpStr As String
tmpFormula = Mid(OldFormula, 2) ' Remove "="
'Call Select_a_part_of_a_formula(tmpFormula, Part1, Repeater1)
'Call Select_a_part_of_a_formula(tmpFormula, Part2, Repeater2)
'Call Select_a_part_of_a_formula(tmpFormula, Part3, Repeater3)
subformula = Split(tmpFormula, "+")
Part1 = "=" & subformula(0)
If (UBound(subformula) = 1) Then
Repeater1 = 1
Part2 = "=" & subformula(1)
End If
If (UBound(subformula) = 2) Then
Repeater2 = 1
Part3 = "=" & subformula(2)
End If
End Sub
Of course since i was unable to follow your logic of breaking formula (when, why where etc), the above function may need to be tweaked a bit
How ever the issue is because of this
Call Select_a_part_of_a_formula(tmpFormula, Part1, Repeater1)
Part 1 is equal to the formula. You are doing it in the code. See the boldline
If (i > 0) Then
If (InStr(Left(Formula, i - 1), "*") > 0) Then
j = InStr(Left(Formula, i - 1), "*")
Repeater = Mid(Formula, j + 1, i - j - 1)
Part = "=" & Left(Formula, j - 1) & "*1.5"
Else
Repeater = 1
Part = "=" & Formula
End If
End If
I dont get all your reasoning. But if "+" in the formula indicates various sub formulas that you want then why not do this
change this
Private Sub Translate(OldFormula As String, _
Part1 As String, Repeater1 As Integer, _
Part2 As String, Repeater2 As Integer, _
Part3 As String, Repeater3 As Integer)
Dim tmpFormula As String, i As Integer, tmpStr As String
tmpFormula = Mid(OldFormula, 2) ' Remove "="
Call Select_a_part_of_a_formula(tmpFormula, Part1, Repeater1)
Call Select_a_part_of_a_formula(tmpFormula, Part2, Repeater2)
Call Select_a_part_of_a_formula(tmpFormula, Part3, Repeater3)
End Sub
to
Private Sub Translate(OldFormula As String, _
Part1 As String, Repeater1 As Integer, _
Part2 As String, Repeater2 As Integer, _
Part3 As String, Repeater3 As Integer)
Dim tmpFormula As String, i As Integer, tmpStr As String
tmpFormula = Mid(OldFormula, 2) ' Remove "="
'Call Select_a_part_of_a_formula(tmpFormula, Part1, Repeater1)
'Call Select_a_part_of_a_formula(tmpFormula, Part2, Repeater2)
'Call Select_a_part_of_a_formula(tmpFormula, Part3, Repeater3)
subformula = Split(tmpFormula, "+")
Part1 = "=" & subformula(0)
If (UBound(subformula) = 1) Then
Repeater1 = 1
Part2 = "=" & subformula(1)
End If
If (UBound(subformula) = 2) Then
Repeater2 = 1
Part3 = "=" & subformula(2)
End If
End Sub
Of course since i was unable to follow your logic of breaking formula (when, why where etc), the above function may need to be tweaked a bit
kaluputha
Posts
5
Registration date
Friday 19 February 2010
Status
Member
Last seen
2 March 2010
21 Feb 2010 à 09:22
21 Feb 2010 à 09:22
if u can make your own macro to do my work.thanks for your reply.....
rizvisa1
Posts
4478
Registration date
Thursday 28 January 2010
Status
Contributor
Last seen
5 May 2022
766
21 Feb 2010 à 09:31
21 Feb 2010 à 09:31
sorry I did not understand what you meant above " If u can make your own macro to do my work."