Could someone please tell me what's wrong with this formula ?
=CONCATENATE(=LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1))-1),"GroupFolder\fileName.png")
Why doesn't the concatenation formula accept the first argument to be an input even though it returns a string?
I'm trying to get the path of a certain file inside the directory of the excel document.
I see no problem with this except a minor typo. Just remove the = sign before the LEFT function. In addition, please take note that CELL function will return nothing if your worksheet is unsaved. So, save your worksheet first.
=CONCATENATE(LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1))-1),"GroupFolder\fileName.png")
Hope this helps..
Related
Please help me with the code to insert a column in excel using vba. Here is what I am doing -
Sheet1.Range("A:A").EntireColumn.insert
That code works fine for me.
Sheet1.Range("A:A").Insert works also. Range("A:A") is already referencing an EntireColumn.
There are a few things to check if it's not working for you:
You're referencing an object called Sheet1. Is that definitely the codename of the worksheet you want to change? Make sure you understand the difference between sheet name and codename. You could try referencing it by the sheet's name instead: Worksheets("Tabname").Range("A:A")...
Is the worksheet protected? That would give you an error if it is.
Is there any data in the right-most column of the spreadsheet? That would also cause an error as Excel doesn't know what to do with it. If you're not 100% sure, select the entire right-most column of the sheet and hit delete to remove anything that might cause an issue.
Lastly, can you insert a column manually? i.e. select left most column, [right-click] and [Insert]?
I think you got the Sheets property wrong, this works for me :
Sheets(1).Range("A:A").EntireColumn.Insert
You should clearly mention what you are trying to do; what type of problem you are facing.
However, you should try out the below code. hope this will help
Sheet1.Range("A:A").EntireColumn.Insert Shift:=xlToRight
while inserting a new row or column make sure to refer to the entire row or column. Check if there are any marge cells at the right of column A. That can possibly be causing the problem.
Sub TryMe()
Columns(1).Insert
End Sub
Also, this is a very generic question. If you can Google something and figure it out in a fraction of the time that it takes to craft a question and post it on SO, just Google it. If your question is very unique, and after hitting multiple dead ends using Google, then ask the SO community. I found the 3 links below using a Google search that took around 1 second.
https://www.automateexcel.com/vba/insert-row-column/
https://excelchamps.com/vba/insert-column/
https://www.educba.com/vba-insert-column/
I'm looking for completely empty comments to delete in VBA. However, the comments are never truly empty since there's always the name of the author (even if he/she put nothing in the comment). I tried various methods, and my approach is to slice the string right after the ":" that goes after the author's name to see if it contains any symbol other than "", the problem is that when you enter a new line in a comment, Excel does not regconize that as a "" to check agaisnt. I have tried to check against vbNewLine but that does not work. Any suggestion would be greatly welcomed.
do a replace: replace(replace(range(xxx).Comment.Text),chr(13),""),chr(10),"") to remove the newlines
I can't figure this out, Maybe you guys can help me.
I need to separate just the image name for example
xxqti8eli5h2f4abpiz2.jpg
lvfdpujvgkf75ve8ikob.jpg
In a separate column, I've a list of 8000 image name which I need to separate out any help from you guys is much appreciated.
http://images.XXX.com/image/upload/s--B3cI5sks--/c_limit,cs_srgb,h_600,w_600/xxqti8eli5h2f4abpiz2.jpg
http://images.XXX.com/image/upload/s--_3R1kbWq--/c_limit,cs_srgb,h_600,w_600/lvfdpujvgkf75ve8ikob.jpg
formula version:
=MID(A1,FIND("}}}",SUBSTITUTE(A1,"/","}}}",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))))+1,LEN(A1))
Since the image is always the last chunk of your string when you separate/split the string by a forward slash, you can use a really tiny UDF to get this functionality.
In a new VBE Module (Alt+F11, then right click your workbook and Insert>>Module), paste the following:
Function get_image(url As String) As String
'extract the last token from the url when it is split by forward slash
get_image = Split(url, "/")(UBound(Split(url, "/")))
End Function
Now you can use this new function in your worksheet:
I'm trying to make a macro that, among other things, updates external file links in several cells, where the file location currently in the cells and that which I want to change it to are specified by the user in another tab.
I've tried to do this via find/replace; if I try to do this with the text specified in the code:
Range("b3").Formula = Replace(Range("B3").Formula, "\\folder\file", "\\folder\newfile")
Then it'll replace this text and the links update correctly. If I change the locations with inputs, say oldlocation and newlocation:
oldlocation= "\\folder\file"
newlocation= "\\folder\newfile"
Range("b3").Formula = Replace(Range("B3").Formula, oldlocation, newlocation)
This also works ok. But if I change the definitions of the locations (e.g. B3: "\folder\file"):
oldlocation= Range("b3").text
newlocation= Range("b4").text
It no longer works - passes over the line in the code with no change or error. I've made a quick check and Range("b3").text & "\folder\file" both seem to be text strings; after that I'm stumped. I've tried a few different find/replace formats I've found, but all with the same result. What am I missing?
The problem is when you define the string to be replaced as
oldlocation= Range("b3").text
the oldlocation variable will have the value of the cell (the data you see in the cell) not the formula of the cell that contains the current reference, so the replace function does not find the string to be replaced.
You have to extract the location that you want to replace from the Range("b3").formula string and work with that.
I am trying to use one of the excel hidden field for the purpose of referencing. Basically column(A:A) is hidden and it contains specific IDs that I can use it to reference it to another sheet.
I could have moved the column (A:A) further away so that the user does not see it, but my issue is that I have written too many lines of code already. I guess it is poorly constructed, because if I were to move any of my columns, my entire program would definitely break. I could try to fix it, but that would mean I would have to over analyze my own code and I either wouldn't understand it or wouldn't find my mistake.
So, anyways, I have a Range.Find function, which is looking in the hidden field, but returns nothing. I could try to unhide it, and hide it again, but I want to know that if there is a solution in Excel, then to not ignore the hidden field.
Set myCell = Columns(1).Find("search_string", lookat:=xlWhole, LookIn:=xlFormulas)
Debug.Print myCell.Row
Replace "search_string" to the ID you are looking for.