Excel VBA select column refence cell formula - excel

I would like to do the following:
Worksheets("Sheet1").Columns("A2").Select
Where in A2 I have the following formula:
=WEEKNUM(NOW())
The formula can be merged probably.
The reference to cell A2 doesn't work.

Worksheets("Sheet1").Columns(Worksheets("Sheet1").Cells(2, 1).Value).Select
worked for me,... I think you just needed one more level of indirection to dig the value out of A2.

Related

Prevent excel updating cell referene with new location

this should be super basic but I can't figure it out.
If I have a series of numbers in A1:A10. And in B1 i have [=A1], B2 [=A2] etc. Simple cell reference.
My problem is that when I select A1:A10 and move them down to A2:A11, the formulas in column B update to reflect the new location. What I want is the reference to be permanently on A1:A10.
I've tied =$A$1, but that too updates to $A$2 when I shift the cells.
How do I break the lock on the values?
It is possible to achieve this using the INDIRECT formula, like this:
B1: =INDIRECT("A1")
B2: =INDIRECT("A2")
...
The references are not updated because they are strings.

Auto Copy and Paste Cell Values not Formula to another Cell

I also need to get your help for the same issue. I need to copy the cell values and not the formulas automatically to the other Cell, "automatically" meaning, I don't need to click, use mouse, or any other means to do that, like once theres a value on that specific cell (which is derived from a formula), the value will automatically be copied and pasted in the other cell (without any intervention from my part) (Only the value is copied not the formula)
Note:
The cell should contain only the copied value and not the formula.
Scenario:
A1 Cell : has 250 value
B1 Cell : has a vlookup formula to search for the value of A1 cell (I need to use VLOOKUP as there's a lot of items in the list, and it is "Dynamic", the reason I cannot just use formula "=A1" to get the value directly)
C1 Cell : Needs to copy and paste only the plain value from B1 cell which is 250, not including the vlookup formula, it should be automatically copied without any intervention (Cannot use VBA code / Macro as it will be run in excel online)
Thanks!!
Just use abasic Excel formula.
Example:
The source data is in cell A1.
You want to copy the same value to cell B1.
In cell B1 write:
=A1
That is all.
Additionally, you need to configure correctly the strategy for calculating the formulas:
I managed to find a solution, sharing as might help someone in the future, just needed to use =value(A1), instead of just "=A1", when I did this, the chart can read the values as it is and not the formula behind it. Found another work around as well, by using the formula =A1+0, for some reason this works too. –
=value(A1) works perfectly , If that formula contains a % figure , simple We can multiply by 100 to get the correct value.

EXCEL - #VALUE on INDIRECT

I'm getting a #VALUE error on an INDIRECT() and can't figure out why. I've never used this function before, so I'd appreciate some pointers.
I'm constructing a string in a cell. The constructed string has a value of the form [items.xls]items!$A$1:$F$30.
For purposes of this question, suppose the constructed string is in cell $A$1 of Sheet1 in workbook1.xls. in cell $B$1, I have =INDIRECT(A1), which I'd hoped would create the actual reference constructed using cell $A$1 so I could use the reference in a VLOOKUP(), but I can't get that far because of the #VALUE error.
I have the workbook items.xls open in excel at the same time as workbook1.xls.
the spreadsheet items exists in workbook1.
what am I doing wrong ?
Because your reference in cell $A$1 is to a range of cells (and not just one cell), you need enter your =Indirect(A1) formula as an array formula.
Select range Sheet1!$B$1:$G$30. 30 rows, 6 columns; the same size as [items.xls]items!$A$1:$F$30.
Type your formula =INDIRECT(A1) into the formula bar. Instead of pressing Enter, press Ctrl+Shift+Enter to complete your formula.
The formula should look like {=INDIRECT(A1)} in the cell.
Check that none of the cells in range [items.xls]items!$A$1:$F$30 has a #VALUE error. If they do, that error will show on your new sheet as well.
Also double-check your formula that constructs the string in cell A1. If part of that formula is returning a #VALUE error, it will pass it on to the INDIRECT() formula.
You can highlight parts of your formula in the formula bar and press F9 to evaluate just that part of the formula. Just remember to hit ESC to exit the cell afterward.
Another alternative is the Evaluate Formula option on the Formulas part of the Excel ribbon menu.

Fixed excel formula (not depending on moving cell)

In D2 cell I have a formula referring to D4 cell value.
Then, I drag&drop D4 cell from D4 to C4, and my D2 cell formula changed.
How to "hardcode" this marked reference to D4 (resulting in 0*2=0)?
Is it possible to make it work without vba?
Try this.
=indirect(address(4,4))*2
Use absolute reference like..
=$D$4*2
Since you aren't doing a vlookup to reference the data (Which is the problem I'm having), try using an INDEX with the limits of excel's table of cells as the braces to prevent it from moving, like this:
=(INDEX($1:$1048576,4,4))*2
That prevents the reference from moving. =D

Using a SUMIF and Drag down formula and change COLUMN references instead of ROWS

I have this forumula on Sheet1 in Cell A1:
=SUMIF(Sheet2!$F:$F,L$11,Sheet2!$L:$L)
As I drag this down to A2,A3, etc... However I need the $L:$L to move across columns as I drag down to reference $M:$M in A2 and $N:$N in A3... etc.
Please Help! I've tried the indirect, index, and offset and have not been able to get anything to work successfully.
Thanks!
Give the following a try in A1 and drag it down.
=SUMIF(Sheet2!$F:$F,L$11,OFFSET(Sheet2!$L:$L,0,row()-1))

Resources