Ask Question Forum:
C
O
M
P
U
T
E
R
2
8
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Y-position of the mouse cursor
Attachment:===
how to use formula, formulaR1C1, formulaarray in VBA and tutorial information

1-Why people are using .formula and .formulaR1C1 in VBA ? Why not directly editing in Excel sheet cell
and put the formula into the activecell such as b2 cell = (A2+A1+A3)/3
is it helping to reduce calcalution time ?
2-I need to handle 2000 excel files and each files may have maximum 35,000 rows and 10 column long data so the number of rows and columnfor each file is different and variable from 3 to 35000
Now I need to do same calculation for each file so I created new workbook and copy/paste those 2000 excel files in open file and copy/paste loop in VBA and I never use set formula/formulaR1C1/formulaArray before
so I just set my formula directly into the workbook sheet like B1 cell value is =A1 and drag the
cell A1 until 35000 row, and final I found the calculation time is really long if put the formulate is more complicated like adding more if condition statement . DO you think I could using
formula()/formulaRC1C1() in VBA to program the different variable of row and column to speed up caluclation
time since we can program variable of row and colume to reduce unneccssary cell calculation for short file data ? Please help on giving those information
3- How to set formula in VBA into region Range like A1:A3500, for example like the following
simple example excel usage . What is formula syntax in VBA ? Please advise and I want to know how to
program variables of row and column in .formula in VBA for range(cells(1,2), cells(i,2) and i can be from
3 to 35000 depend on the file open
Sub cal()
Dim a as integer
a= 35000
range(cells(1,2), cells(a,2)).formula= "= A & a" 'B1 value = A1+2 B2 value=A2+2..and so on...until B35000
End Sub
Excel Sheet
A B
==========
1 9 =A1+2 'So b1 value =11
2 10 =A2+2 'So b2 value = 12
3 15 =A3+2 'So b3 value = 17
4
It works fine and thanks for your reply
After benchmark test,directly
put formaula into excel sheet
is just a little faster but not much
than using VBA formulaRC for
45 files with 15000 rows files
Duncan
It works fine and thanks for your reply
After benchmark test,directly
put formaula into excel sheet
is just a little faster but not much
than using VBA formulaRC for
45 files with 15000 rows files
Duncan
It works fine and thanks for your reply
After benchmark test,directly
put formaula into excel sheet
is just a little faster but not much
than using VBA formulaRC for
45 files with 15000 rows files
Duncan