![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 8
|
Hey!
I'm v.new to macros & the like so i need some advise. I have a task i need to automate as I seem to have to do it manually 10 times a day. I just need help with the principle really - so, hypothetically, if i was recording a macro to just multiply cell A1*B1 in cell C1,; I could have a file that has just 5 rows with A & B values, but other files may has 20,0000 A & B values. What is the most efficient way to do this so after the macro runs I have no tidying up to do? - i say this as the way i would do it at the moment is to copy cell C1 through to C65536, and when i get a file with just 6 rows i have to clear the remaining 65531 cells! |
|
|
|
|
|
#2 |
|
New Member
Join Date: Apr 2002
Posts: 15
|
put this in c1 then fill down
this will check if the a1 or b1 is empty if so it will make c1 empty if a1 and b1 have number in them then it will multiply them =IF(OR(A1="",B1=""),"",A1*B1) |
|
|
|
|
|
#3 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Sub Tester() [C1].FormulaR1C1 = "=RC[-2]*RC[-1]" [C1].AutoFill Destination:=Range("C1:C" & [A1].End(xlDown).Row) End Sub Assumes 1) Data starts in A1 & B1 2) No gaps in data columns This places the formula =A1*B1 in C1 (Using R1C1 format) Uses AutoFill instead of copying Gets last Row from the VBA use of End(Xldown) The equavalent Keyboard command is Selecting a cell and pressing END then the arrow key...this takes you to the Last populated cell in the specified direction which in this case is Down. |
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Mar 2002
Posts: 62
|
Cheers Chaps!
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|