I have a column of part numbers which I would like to associate with a column of links to their corresponding autocad drawings. The drawings are on a server, I would like to be able to insert the part number into the file path.
My attempt:
=HYPERLINK(\\servername\folderofparts\partprefix\['Lists for Calculations'!B8].dwg","Link")
where cell B8 within the sheet Lists for Calculations contains the name of the part.
try,
=HYPERLINK("\\servername\folderofparts\partprefix\" & 'Lists for Calculations'!B8 & ".dwg", "Link")
tbh, it's a little unclear whether the square brackets were intended to be part of the filename or not. I removed them above.
Related
I have an Excel file which includes lots of rows of information. I have actually a single problem which is I can't get the parent of each cells according to the information in the cell. It looks like this
In the image, you can see that A has no parent and its' children are A01 and AB and more and more like AC and AD. Is there any way for handling this issue with excel-formulas?
Assuming that your sample data is true to the format of all your data (there is either 2 numbers at the end of each parent or only an extra letter) then the following formula will work:
Given formula is set to look at data in cell A1, you will have to drag and auto fill the formula down for all rows.
=IF(OR(RIGHT(A1,1)="0",RIGHT(A1,1)="1",RIGHT(A1,1)="2",RIGHT(A1,1)="3",RIGHT(A1,1)="4",RIGHT(A1,1)="5",RIGHT(A1,1)="6",RIGHT(A1,1)="7",RIGHT(A1,1)="8",RIGHT(A1,1)="9")=TRUE,LEFT(A1,LEN(A1)-2),LEFT(A1,LEN(A1)-1))
It works by checking if the last character is a number (with this data excel treats it as text so we have to check for each number as if it is text), if it matches a number then show the parent minus the two right characters otherwise show the parent minus one character.
Okey I think I found the answer. Here is my formula
=IF(LEN(B2)=1;"NULL";IF(LEN(B2)=2;LEN(B2;0);IF(LEN(B2)=3;LEFT(B2;1);IF(LEN(B2)=4;LEFT(B2;3);IF(LEN(B2)=5;LEFT(B2;4);IF(LEN(B2)=7;IF(B2;5)))))))
With this formula, I check the length of the characters in cell and get the first part of that string instead of deleting the last indexes because of there are also some string values.
Because of there are some rules with my product codes, I figured out how they are changing and I got the part of the code by their sizes. Thanks for replies, they helped to find this solution.
I'm basically looking for a $A:$A equivalent for structured table references in Excel.
Say I have this formula:
=INDEX(tChoice,MATCH(OFFSET(tData[#[cm_sex]],-3,0),tChoice[name],0),3)
Basically tData is a table full of raw data (many columns), taken from surveys (so each column is Survey question, more or less). tChoice is a smaller table (just a few columns), I basically want to look up into tChoice the raw data value & return a label based on that (to value-label table is tChoice).
I actually want the tData[#[cm_sex]] to auto-increment as I apply formulas in cells to the left (so I cycle through all the columns of the raw data), however I DON'T want the column tChoice[name] to change: e.g. the column to look for a match based on the raw table data.
This is equivalent to writing, say, A:A (which would auto-increment to B:B, C:C, etc) and $A:$A (which would not).
Is there a dollar sign equivalent for structured table references?
P-S: Of course I can other things like increment the whole thing, than search & replace the range with say tChoice[*] replaced by tChoice[name]... However it would be cleaner & more efficient to have a proper notation for it....
Didn't find it in the support pages (https://support.office.com/en-us/article/Using-structured-references-with-Excel-tables-f5ed2452-2337-4f71-bed3-c8ae6d2b276e)
user3964075 provided the answer in the comments. I had never seen this before so thanks to him or her for this answer. There's some information out there on the web about absolute structured table references, so I thought I'd summarize what I found.
For your situation you can use tChoice[[name]:[name]] Specifying a range that's just the one column anchors the column like $ signs do in normal cell references.
If you want to just deal with one row (the one that the formula is in) the anchor looks like this:tChoice[#[name]:[name]].
Now say you want to anchor one cell but have the other be relative, as in this scenario where I'm summing from a to the right, starting with a:a, then a:b, etc:
You can do that with a formula like this, where the first part is absolute and the second is relative:
=SUM(Table1[#[a]:[a]]:Table1[#a])
Note that these formulas much be dragged, not copied. Perhaps there is a keyboard shortcut that does this.
This process is rather clunky compared to just clicking F4, as with a regular cell reference. Jon Acampora has created an addin that automates this process, as well as two detailed posts on this topic. His first post contains a link to the one with the addin.
Can Not Get My VLookUp In Excel To Return The Requested Data
I am trying to pull data from another sheet based on data selected from a dropdown on the main sheet.
All the formatting is "General"
=VLOOKUP(F15737,'Location Master'!$A:$J,2,FALSE)
It just keeps returning me #N/A
Try using the Index Match method. It's an alternative to Vlookup which doesn't require data to be sorted and can therefore be of more use.
The typical structure of this method is (the text inside the asterisk will give the ranges specific to your sheet:
=INDEX (**Column from which you want to return a value**, (MATCH(**Lookup Value**, **Column against which you want to lookup**,0))
In this case, if I've understood your workbook structure, the formula should look like this:
=INDEX('Location Master'!$B:$B,(MATCH(F15737,'Location Master'!$A:$A,0)))
This is a common problem with VLOOKUP(). Most likely you have some whitespace (A tab character or some spaces) after one of the values. Click on F15737 and see if there are any spaces at the end of it. Likewise, manually find the value in 'Location Master'!$A and check it for spaces or tabs after the value.
If the whitespace is found in F15737 then you can change your vlookup to be:
=VLOOKUP(TRIM(F15737),'Location Master'!$A:$J,2,FALSE)
If the whitespace is in the range to which you are looking up, then you'll need to trim all of those values, which you can do pretty quickly in a new column with the TRIM() formula.
If this doesn't solve the problem then you might have a number stored as text. Generally excel will tell you if this is the case within the cell with a little green corner indicator. To get Excel to automagically change a column from a "Number stored as Text" to a proper number you can:
Highlight the column
Go to Data>>Text To Columns
Click "Fixed Width"
Click "Finished"
Excel will then format everything automatically (dates to dates, numbers to numbers, text to text, time to time, etc.)
Many "advanced" (aka: VBA) excel tutorials on the web or even excel's vba help encurage us to use the
Range("B2:B10")
method (to be precise: object) for selecting cells or getting values. In the same place they often add it's totally ok to use predefined names as well:
Range("valuesabove")
On the other hand I fell in love with the incredible power of relatively defined cell names. They make it so much easier to write and handle big composite formulas, and basically to refer to nearly anything.
However, relative names don't work in the Range("valuesabove") method the way we are used to it.
Usually (when used on the worksheet) relative names are relative to the currently selected cell or to the cell in which they are used.
In VBA's Range() object this is not true. Range is relative to a WorkSheet object, by default to the ActiveSheet. But ActiveSheet is represenetd by its leftupper cell, A1. And this is what Range turns out to be relative to. And this is why absolute names ($C$23) do work with it, and relative ones ("one column to the left, two rows up") don't.
So my question is:
How can I harness the power of relative names in VBA then?
EDIT:
Realising that my question was rather unclear (thx's go to you guys commenting tirelessly) let me try to put it in a specific form and clarify terms:
IMHO on an excel worksheet it is very comfortable to use names in order to refer to cells or define calculated values by functions based on cell values.
In excel a reference to a cell can be either relative, absolute, or mixed. This is true also when creating names. Thus we can speak about absolute, relative or mixed names (in terms of referring of course).
Here an absolute name is used a couple times (created using excel's Trace Dependents function):
Name "name" = $D$2
A relative name is used a couple times here:
Name "upright24" while, e.g. cell A7 is selected = C3 (without $ signs!). But this changes constantly according to the selected cell or region. You can check it in the name manager! (Ctrl+F3)
And this is what we can consider as a mixed name:
Name "rel_serialnumber" while, e.g. cell C6 is selected = $B6. The row of which (6) changes constantly according to the selected cell or region.
The creation of a relative or a mixed name is explicitly based on the active cell at the moment of creating the name. The creation of an absolute name naturally doesn't rely on the cursor position.
Note, that
absolute names mean a dinamic offset from the referenced cell, which is one and only
relative names mean a static offset from the referenced cell, which thus changes always corresponding to the place where the name is used
mixed names mean a mixed (or half-dynamic) offset from the referenced cell, the row or column of which thus changes always corresponding to the place where the name is used while the other remains always the same (the offset in one or the other direction remains zero).
Okay, now here is the thing. I have a database-like excel sheet where I handle the rows like records and the columns as fields for properties. The user uses this thing as follows: he "selects a record" by placing the cursor in any cell of the row of the desired record. Then he presses a big command button which starts my VBA macro. This intends to open a prepared skeleton file and fill some specific cells in it (which are btw defined by absolute names) with some values (which are defined by mixed names) from the selected record.
Since Range("name") is considered ok to use in VBA (see above) I thought Range("relativename") or Range("mixedname") will work just as fine while automatically relying on the active cell.
I couldn't be worse.
Only Range("absolutename") works in the way one would expect! Explanation see above.
So I'm after a function / method / object that is possibly as comfortable to use with a "relativename" or a "mixedname" as Range("absolutename") is.
It appears you are looking for Range.Offset() http://msdn.microsoft.com/en-us/library/office/ff840060%28v=office.15%29.aspx
However you could do it as:
'Your example Range(Col_B_in_current_row) as
Range("B" & ActiveCell.Row).Select
'Your example Range("B2:B10") -> Range("valuesabove") as
Range("B2:B10").Offset(-1, 0).Select
Just seems like a relatively simple syntax already exists for this.
I think I've found a proper and compact solution. It's
Names("mixedname").RefersToRange
Not as short as Range("mixedname") would be but it is really providing the expected values.
UPDATE:
This solution is mostly unuseful if you want to copy relative-named cell values in a source workbook to relative-named cells in a dest workbook with a single codeline. This is because Names() relies on the actual position of the cursor which is depending on which workbook is currently the active one and in most cases this won't be ok for the other.
In this case the non-fixed part of the name has to be stored:
sourcerow = ActiveCell.Row
[...]
'opening a wbk, this also makes it the active one
[...]
Names("dest").RefersToRange = mysheet.Cells(sourcerow, mybook.Names("src").RefersToRange.Column)
To reference a Range relative to another Range you can use this syntax:
myRange.Range("namedRange")
Note: This only works if both the Row offset AND the Column offsets are positive. For example if the "Refers to" formula for the named range is "=Offset(A1,r,c)", then the above syntax will throw an error if Either r Or c is negative. But, it will work if both are positive.
The asymmetry is unfortunate but business as usual for VBA...
To Reference the third column in the row of the current ActiveCell:
ActiveCell.EntireRow.Range("C1")
To reference a cell offset by (for example) 1 row and 3 columns relative to the ActiveCell:
ActiveCell.Range("C2")
Obviously, you can use the same syntax with the Selection Object or any other Range value in VBA.
Private Sub Worksheet_Change(ByVal Target as Range)
If Not Intersect(Target.Address,ThisWorkbook.Sheets('sheetname).Range('RangeName)) Is Nothing Then _
'Do whatever you want down here.
ThisWorbook.Sheets('sheetname).Range('RangeName).Offset(0,Target.Row)
End If
End Sub
This should send you on the right path to what you want (which is super unclear). Use the worksheet change event to bring in user worksheet selections and changes into VBA modules. Put it into the relevant sheet.
I had the same problem, but I did get it to work - sort of. I don't know what is different about the simple example below, but it works. At first I thought selection mattered, but no - it works without changing the active cell.
(I still can't get it to work in my main spreadsheet.)
Named range: "TestName" = Sheet1!$H1
Values in H1:H10 = 1,2,3,4,5,6,7,8,9,10
Sub Test()
Dim x As Integer
For x = 0 To 10
Range("A1").Offset(x, 0).Value = Range("A1").Offset(x, 0).Range("Testname").Value
Next x
End Sub
Result: A1:A10 = 1,2,3,4,5,6,7,8,9,10
So here is a problem that I have never come across before. I Import an ISIN (for example DE0002635307) from a cell, which is defined as a text. I need to use this to reference to a cell by that name. So:
sub ISINWriter
dim ISIN as String
ISIN = ThisWorkbook.Sheets(i).Cells(j, 4).Value()
ThisWorkbook.Sheets(i+1).Cells(f, 4).Formula = "=" & ISIN
End Sub
For most of the ISINs this works fine, except if there are 4 or more zeros in a row. If that happens - for example FR0000120073 - it writes "=FR120073" into the cell. It just eats the zeros INSIDE the string! Any ideas?
I use Excel 2010 and Windows 7.
Thanks a lot.
If you use the Name Manager to try to create a named range (or more accurately a named formula) called "FR0000120073" then you should find that you get an error. Something like (from Excel 2007 on my machine):
The name that you entered is not valid.
Reasons for this can include:
- The name does not begin with a letter or an underscore
- The name contains a space or other invalid characters
- The name conflicts with an Excel built-in name or the name of another object in the workbook
The clue is in the last part of the third reason. FR120073 is a valid cell address in these days of 16Kx1m cell worksheets.
The first reason above may be useful, though: _FR0000120073 is a valid name. Could you use that?
EDIT: Removing my last answer so this makes sense.
Basically your cell references are an AlphaNumeric value. Take A1 for example A is the column 1 is the row. This issue is occuring because 0001 is the same as 1. so a reference to cell A001 is going to be the same as cell A1.
It looks like Excel has some built in functionality to remove leading 0's from your references to cells.