Advanfill từ giữa 2 sheet vba
I want to get values from other sheets. I have some values in Excel (sheet2) for example:
I sum each column in row 4. I'm working with these values in sheet2 but I want to get the result in sheet1. When using my code in sheet2 I get the correct answer but when I try to use it in a different sheet I get the result of the values corresponding to the current sheet cells and not to sheet2. I'm using How can I set sheet2 as the active sheet?
asked Nov 10, 2010 at 20:29
Try
to access a range in sheet 2 independently of where your code is or which sheet is currently active. To make sheet 2 the active sheet, try
If you just need the sum of a row in a different sheet, there is no need for using VBA at all. Enter a formula like this in sheet 1:
answered Nov 10, 2010 at 20:35
Doc BrownDoc Brown 19.3k6 gold badges51 silver badges87 bronze badges That will be (for you very specific example)
OR
So get a F1 click and read about Worksheets collection, which contains Worksheet objects, which in turn has a Cells collection, holding Cell objects... answered Nov 10, 2010 at 20:35
jpinto3912jpinto3912 1,4652 gold badges11 silver badges19 bronze badges
This will compare two sheets cells values and if they match place the value on sheet 2 in column L. answered Jul 16, 2016 at 8:16
James HefferJames Heffer 6461 gold badge6 silver badges17 bronze badges 4
did not work. However the following code only worked for me.
answered May 11, 2015 at 6:33
RanonKahnRanonKahn 7878 silver badges30 bronze badges 6 Try the worksheet activate command before you need data from the sheet:
DimaSan 11.7k11 gold badges65 silver badges74 bronze badges answered Jun 20, 2017 at 13:20
Maybe you can use the script i am using to retrieve a certain cell value from another sheet back to a specific sheet.
You can make a form using this and personalize it as needed. answered Aug 23, 2019 at 4:50
Usually I use this code (into a VBA macro) for getting a cell's value from another cell's value from another sheet: Range("Y3") = ActiveWorkbook.Worksheets("Reference").Range("X4") The cell Y3 is into a sheet that I called it "Calculate" The cell X4 is into a sheet that I called it "Reference" The VBA macro has been run when the "Calculate" in active sheet. answered Jul 24, 2020 at 20:31
KasraKasra 1054 silver badges13 bronze badges |