Need to Use Excel Worksheet Formulas and Formatting into Values using VBA..
Dear Board,
I have finalized particular formatting and specific formulas for each different column..
Now I need to use the same Formatting Information and also use the same Formulas however in the VBA. approach.
Example:
The Matrix Range where I need to use the Formatting and Formulas starts from the Column A10 till Column K unlimited depending on certain criteria..
I have formulas for each column i.e Cells A10 till K10..
Now the formula in the Cell A10 should be copied till a certain Last Row which I can derive, however I need to use it in such a way that the entire Column A10:A110 ( assuming 110 is the last row till which i need the formula to be filled)
Then how do I put the formatting and then the formula and then convert all this into values..
This is the Formatting Information and also the Formula for the first cell i.e. A10 which needs to be there till the last row = 110.
Now this was a very simple and compact formula however, in the next cell i.e. B10 there is a mcuh bigger formula which has an INDIRECT function as well as it is an ARRAY formula.
Now the problem in using the formulas is of the double quotes and also of the single quotes.
So, I was trying to use the Substitute Function to convert the regular worksheet formulas into VBA type formulas by replacing each pair of double quote with double pair.
Please someone guide me on how do I use the same..efficiently where I can use the same formulas and the formatting but in a better manner using VBA.
Thanks in advance.
Regards
all4excel
Dear Board,
I have finalized particular formatting and specific formulas for each different column..
Now I need to use the same Formatting Information and also use the same Formulas however in the VBA. approach.
Example:
The Matrix Range where I need to use the Formatting and Formulas starts from the Column A10 till Column K unlimited depending on certain criteria..
I have formulas for each column i.e Cells A10 till K10..
Now the formula in the Cell A10 should be copied till a certain Last Row which I can derive, however I need to use it in such a way that the entire Column A10:A110 ( assuming 110 is the last row till which i need the formula to be filled)
Then how do I put the formatting and then the formula and then convert all this into values..
This is the Formatting Information and also the Formula for the first cell i.e. A10 which needs to be there till the last row = 110.
Code:
.Address = $A$10
.NumberFormat = "General"
.Formula = "=IF(ROWS($A$10:$A10)<=PassCnt,ROWS($A$10:$A10),"""")"
.HorizontalAlignment = -4108
.VerticalAlignment = -4107
.IndentLevel = 0
.Orientation = -4128
.WrapText = False
.ColumnWidth = 3.64
.RowHeight = 15
.Font.Name = "Book Antiqua"
.Font.Size = 11
.Font.Bold = True
.Font.Italic = False
.Font.Underline = -4142
.Font.Color = 8388736
.Font.ColorIndex = 13
.Font.Superscript = False
.Font.Subscript = False
.Font.Strikethrough = False
Now this was a very simple and compact formula however, in the next cell i.e. B10 there is a mcuh bigger formula which has an INDIRECT function as well as it is an ARRAY formula.
Code:
"=IF(OR($A10="",ISBLANK(INDEX(INDIRECT("'"&$D$2&"'!$A$2:$Z$"&LastRow1),SMALL(IF((INDIRECT("'"&$D$2&"'!$E$2:$E$"&LastRow1)>=$C$5)*(INDIRECT("'"&$D$2&"'!$E$2:$E$"&LastRow1)<=$C$6),ROW(INDIRECT("'"&$D$2&"'!$E$2:$E$"&LastRow1))-ROW(INDIRECT("'"&$D$2&"'!$A$2"))+1),ROWS(B$10:B10)),MATCH(B$9,INDIRECT("'"&$D$2&"'!$1:$1"),0)))),"",INDEX(INDIRECT("'"&$D$2&"'!$A$2:$Z$"&LastRow1),SMALL(IF((INDIRECT("'"&$D$2&"'!$E$2:$E$"&LastRow1)>=$C$5)*(INDIRECT("'"&$D$2&"'!$E$2:$E$"&LastRow1)<=$C$6),ROW(INDIRECT("'"&$D$2&"'!$E$2:$E$"&LastRow1))-ROW(INDIRECT("'"&$D$2&"'!$A$2"))+1),ROWS(B$10:B10)),MATCH(B$9,INDIRECT("'"&$D$2&"'!$1:$1"),0)))"
Code:
.Address = $B$10
.Value = CHQ
.NumberFormat = "General"
.HorizontalAlignment = -4108
.VerticalAlignment = -4108
.IndentLevel = 0
.Orientation = -4128
.WrapText = False
.ColumnWidth = 7.55
.RowHeight = 15
.Font.Name = "Book Antiqua"
.Font.Size = 11
.Font.Bold = True
.Font.Italic = False
.Font.Underline = -4142
.Font.Color = 6299648
.Font.ColorIndex = 49
.Font.Superscript = False
.Font.Subscript = False
.Font.Strikethrough = False
Now the problem in using the formulas is of the double quotes and also of the single quotes.
So, I was trying to use the Substitute Function to convert the regular worksheet formulas into VBA type formulas by replacing each pair of double quote with double pair.
Please someone guide me on how do I use the same..efficiently where I can use the same formulas and the formatting but in a better manner using VBA.
Thanks in advance.
Regards
all4excel