'Divide a set number of columns in one sheet1, with a set number of columns in Sheet2
I'm trying to divide a set number of columns (A to BL) in sheet1, with the same number of columns in sheet2. Each cell in the first sheets range should be divided by the same cell in the second sheet.
The numbers of rows however are dynamic. (the same between sheets, but number per sheet will change weekly)
Im also trying to paste the answers into sheet 3.
I've been trying to build off of recorded macros but am not getting anywhere.
Sub Macro5()
Range("A1").Select
ActiveCell.Formula2R1C1 = "=Result2!R[1]C[1]:R[6]C[4]/Result!R[1]C[1]:R[6]C[4]"
Range("E15").Select
End Sub
Solution 1:[1]
This macro is auto-generated, using the steps I outlined in my comment above. It only copies one row for columns A thru C, but you said your set will be variable, so you can customize as you see fit.
Sub DivideSheet1ValuesBySheet2Values()
'Copy numerators and paste them into a new Sheet3
Range("A1:C1").Select
Selection.Copy
Sheets("Sheet2").Select
Sheets.Add After:=ActiveSheet
ActiveSheet.Paste
'return to Sheet2 and copy the denominators to clipboard
Sheets("Sheet2").Select
Range("A1:C1").Select
Application.CutCopyMode = False
Selection.Copy
'Activate Sheet3 and Paste Special - Divide
Sheets("Sheet3").Select
Range("A1:C1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlDivide, SkipBlanks _
:=False, Transpose:=False
End Sub
Procedure
- Copy the numerator set from Sheet1 to Sheet3
- Copy the denominator set (Sheet2 values) to the clipboard
- Do a Paste Special... -> Divide, which dumps the clipboard values onto the values in Sheet3 while applying a division calculation.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
