Notepad++ Which regex or macro to bookmark next lines[of a previously searched word] without manually select them? - line

Which regex or macro to bookmark next lines without manually select them?
I mean this:
before:
after:

Macro is: F3, Down arrow, Ctrl+F2.

Related

Excel using Replace on Formulas

I have a bunch of formulas all over different rows and columns in my Excel sheet. Some of the formulas are of the form: =($B$12-G12)*$B$3*G3
All I want to do is replace the ")" with ")^2". I tried using the Ctrl + F -> Replace section to look in Formulas but for some reason Excel says cannot find a match...All the cells I am trying to replace are of the form:
=(Cell1-Cell2)*Cell 3*Cell4
I just want to replace that )* by ^2*
What can I do?
This is what I have tried searching:
Make sure the Look in option is set to Formulas:
EDIT#1:
As per your comment, you must use tilda in the Find string:
Find and search using:
)~*
What I was having difficulty with was the * and I found the solution is to just use a ~ and it will fix the problem.
In summary of the article I left as a comment (http://www.mrexcel.com/archive/General/29013.html), you need to use ~ [the character to the left of the 1 on a standard English QWERTY keyboard] before *, in order to specifically tell excel that you want to look for an asterisk, not use the asterisk as a wildcard.

Double quotes from excel query when copy/paste from Excel into SQL Server 2012

I have a query Excel in each of my rows, about 2000. When I copy paste all queries into SQL Server roughly 100 rows are showing a error. Might not even be an error but the query will paste into SQL Server with double quotes in front of entire query.
I have error checking in place so it has something to do with the data in my Excel sheet. My query pasted in SQL Server for instance:
"insert into
I cannot paste the entire query or any data, sorry.
Thank you for looking at this
Actually a lot easier then all of the posts here,
in another column do the following formula:
=CLEAN(MyCell)
This occurs when a line has an embedded carriage return, it may happen in other situations as well. I just do a find/replace for double quotes in the resulting query, but you could also first paste it into Word then copy from there and it will paste without the quotes.
Alternatively, if it's just from embedded returns you could wrap your formula in a pair of SUBSTITUTE() functions to remove CHAR(13) and CHAR(10) if formula was in A1:
=SUBSTITUTE(SUBSTITUTE(A1,CHAR(13),""),CHAR(10),"")
When you are typing your SQL query in the Excel cell never hit Enter, just keep typing all in a single line regardless of how long it is.
If you have queries already entered, double-click on the cell to go to the edit mode and start removing any new lines you have already entered.
The simplest way is to copy from the Formula Bar instead of from the cell.
When you have multiple lines in the cell, Excel will fill the clipboard with a CSV-representation of the cell. That means: double quotes added around, and the double quotes inside the string are escaped with yet another double quote.
Not: select the cell, Ctrl-C
But instead: select the cell; in the formula bar, highlight the complete text (cursor at start, press shift, press arrow-down until the last character is highlighted), Ctrl-C.
and paste in the target application (Notepad, or browser-entry form, or...)
An easier way to select all the text from inside the formula bar would be nice...
Paste the MS Excel content into MS Word with "Keep Source Formatting" pasting option and then copy and paste it to SQL/XML.
I have found that a tab in an excel file will also cause this behavior.
STEPS TO CREATE PROBLEM CITED BY OP
Find a table create script where all the fields are tabbed in 1 tab
copy that to excel Do some sql generation macro in a second column
(Col E, because A-D were consumed by the text to col operation ) Copy
Col E Paste into Visual Studio
You just reproduced the problem op has.
FIX
Go
to the table create script Hightlight all the columns
SHIFT-TAB until they are all at column 0
Paste that list of fields back into Excel.
Redo the TEXT TO COL operation
(the macro should still be good, check it to be sure)
Recopy the COL E to Visual
Studio
You should have just solved the problem.
I have to say that "Spacez" give the best answer. he give the road to find the real answer.
Sub CopyCellContents()
'create a reference in the VBE to Microsft Forms 2.0 Lib
' do this by (in VBA editor) clicking tools - > references and then ticking
"Microsoft Forms 2.0 Library"
Dim objData As New DataObject
Dim strTemp As String
strTemp = ActiveCell.Value
objData.SetText (strTemp)
objData.PutInClipboard
End Sub
Although this question is quite old, I still found this link when googling. So I think it should be good to leave the thread I've found and works good for me.
Leave out quotes when copying from cell

Copy ComboBox from a Word Document to another Word Document with vba

I have a combo box (combo1) in a word document and I would like to copy it to another word document. (end game will be looping through 100's of docs).
I can't for the life of me work out how to select and/or copy the combo box, although its easy enough to do outside of vba.
So far I've tried turning it into a bookmark, seems to select ok, but won't copy.
ActiveDocument.Bookmarks(combo1_bm).Select
Selection.Copy
I thought it would be able to done as an inline shape (as that is how they are added?), however again the selection appears to work, but the Copy doesn't.
ActiveDocument.InlineShapes(combo1).Select
Selection.Copy
Any ideas on what I can try next?
Cheers,
Michael
Your attempt with bookmark was quite good. You just need to extend your code a bit:
ActiveDocument.Bookmarks("combo1_bm").Range.Copy
....
Selection.Paste 'or different pasting procedure
Keep in mind that you don't need to select object before copy it. Just try doing as I show above. Moreover, don't miss quotation marks for names or use bookmark index to work with appropriate one. Copy method will copy inside range of the bookmark and keep original bookmark in place, unchanged.
This should do the trick.
Set ComboBox1Range = ActiveDocument.Range(Start:=ActiveDocument.Bookmarks("combo1_bm").Range.Start - 1, _
End:=ActiveDocument.Bookmarks("combo1_bm").Range.End)
ComboBox1Range.Expand Unit:=wdParagraph
ComboBox1Range.Copy

Word macro to go to a particular word count position?

I'm looking for a macro solution that will search for a particular word in the word count. Say I'm up to word 23,050 in a document (I work with book-length manuscripts) I would like to be able to go to that word. The normal go-to command will go to a line or a page but not a word. Any ideas?
Try this:
Option Explicit
Sub GoToWord(lWord As Long)
ThisDocument.Words(lWord).Select
Selection.Collapse
End Sub
The first command will select the desired word in the document, the second command will put the cursor at the beginning of that word. Note that the Wordscollection used includes punctuation marks.

How do I convert a column of text URLs into active hyperlinks in Excel?

I have a column in excel, wherein I have all the website url values. My question is I want to turn the url values to active links. There are about 200 entries in that column with different urls in all cells. Is there a way I can create active hyperlinks to all the cells without writing a macro.
If you don't want to make a macro and as long as you don't mind an additional column, then just create a new column alongside your column of URLs.
In the new column type in the formula =HYPERLINK(A1) (replacing A1 with whatever cell you are interested in). Then copy the formula down the rest of the 200 entries.
NOTE: This solution does not work if the cell A1 contains a string longer than 255 characters. It results in a #VALUE! error
Create the macro as here:
On the Tools menu in Microsoft Excel, point to Macro, and then click Visual Basic Editor.
On the Insert menu, click Module.
Copy and paste this code into the code window of the module.
It will automatically name itself HyperAdd.
Sub HyperAdd()
'Converts each text hyperlink selected into a working hyperlink
For Each xCell In Selection
ActiveSheet.Hyperlinks.Add Anchor:=xCell, Address:=xCell.Formula
Next xCell
End Sub
When you're finished pasting your macro, click Close and Return to Microsoft Excel on the File menu.
Then select the required cells and click macro and click run.
NOTE Do NOT select the whole column! Select ONLY the cells you wish to be changed to clickable links else you will end up in a neverending loop and have to restart Excel!
Done!
Pretty easy way for rather short lists:
Double click on the box where the url is
Enter
You have your link ;)
Here's a way I found. I'm on a Mac using Excel 2011.
If column B had the text values you want to be hyperlinks, put this formula in the cell C1 (or D1 or whatever as long as it's a free column): =HYPERLINK(B1,B1)
This will insert a hyperlink with the location as the link text and the "friendly name" as the link text. If you have another column that has a friendly name for each link, you could use that too.
Then, you could hide the text column if you didn't want to see it.
If you have a list of IDs of something, and the urls were all http://website.com/folder/ID, such as:
A1 | B1
101 | http://website.com/folder/101
102 | http://website.com/folder/102
103 | http://website.com/folder/103
104 | http://website.com/folder/104
you could use something like =HYPERLINK("http://website.com/folder/"&A1,A1) and you wouldn't need the list of urls. That was my situation and worked nicely.
According to this post: http://excelhints.com/2007/06/12/hyperlink-formula-in-excel/ this method will work in Excel 2007 as well.
OK, here's a hokey solution, but I just can't figure out how to get Excel to evaluate a column of URLs as hyperlinks in bulk.
Create a formula, ="=hyperlink(""" & A1 & """)"
Drag down
Copy new formula column
Paste Special Values-only over the original column
Highlight column, click Ctrl-H (to replace), finding and replacing = with = (somehow forces re-evaluation of cells).
Cells should now be clickable as hyperlinks. If you want the blue/underline style, then just highlight all cells and choose the Hyperlink style.
The hyperlink style alone won't convert to clickable links, and the "Insert Hyperlink" dialog can't seem to use the text as the address for a bunch of cells in bulk. Aside from that, F2 and Enter through all cells would do it, but that's tedious for a lot of cells.
If adding an extra column with the hyperlinks is not an option,
the alternative is to use an external editor to enclose your hyperlink into =hyperlink(" and "), in order to obtain =hyperlink("originalCellContent")
If you have Notepad++, this is a recipe you can use to perform this operation semi-automatically:
Copy the column of addresses to Notepad++
Keeping ALT-SHIFT pressed, extended your cursor from the top left corner to the bottom left corner, and type =hyperlink(". This adds =hyperlink(" at the beginning of each entry.
Open "Replace" menu (Ctrl-H), activate regular expressions (ALT-G), and replace $ (end of line) with "\). This adds a closed quote and a closed parenthesis (which needs to be escaped with \ when regular expressions are activated) at the end of each line.
Paste back the data in Excel. In practice, just copy the data and select the first cell of the column where you want the data to end up.
I shocked Excel didn't do this automatically so here is my solution I hope would be useful for others,
Copy the whole column to clipboard
Open this on your Chrome or Firefox
data:text/html,<button onclick="document.write(document.body.querySelector('textarea').value.split('\n').map(x => '<a href=\'' + x + '\'>' + x + '</a>').join('<br>'))">Linkify</button><br><textarea></textarea>
Paste the column on the page you just opened on the browser and press "Linkify"
Copy the result from the tab to the the column on Excel
Instead step two, you can use the below page, first, click on "Run code snippet" then paste the column on it
<button onclick="document.write(document.body.querySelector('textarea').value.split('\n').map(x => '<a href=\'' + x + '\'>' + x + '</a>').join('<br>'))">Linkify</button><br><textarea></textarea>
This method works for me using the hyperlink function:
=HYPERLINK("http://"&B10,B10)
Where B10 is the cell containing the text version of the URL (in this example).
With Excel 2007 on Windows, I found these steps simplest;
Select cells with the non-active URLs
Copy
Paste as hyperlink
Create a temporary new column of hyperlinks using formula =HYPERLINK()
Copy that column into Microsoft Word (copy to clipboard only after Word is running).
Copy everything in the new word document (ctrl+a, then ctrl+c).
Paste into Excel, replacing the original column of text. Delete the temporary column with the formula.
I found that none of the methods here worked if the hyperlink did not include http:// as they linked to local locations.
I also wanted to fool-proof the script as the users would not be able to maintain it themselves and I would not be available.
It will only run on cells in a selected range if they contain a dot and no spaces. It will only run for up to 10,000 cells.
Sub HyperAdd()
Dim CellsWithSpaces As String
'Converts each text hyperlink selected into a working hyperlink
Application.ScreenUpdating = False
Dim NotPresent As Integer
NotPresent = 0
For Each xCell In Selection
xCell.Formula = Trim(xCell.Formula)
If xCell.Formula = "" Or InStr(xCell.Formula, ".") = NotPresent Then
'Do nothing if the cell is blank or contains no dots
Else
If InStr(xCell.Formula, " ") <> 0 Then
CellsWithSpaces = CellsWithSpaces & ", " & Replace(xCell.Address, "$", "")
GoTo Nextxcell
End If
If InStr(xCell.Formula, "http") <> 0 Then
Hyperstring = Trim(xCell.Formula)
Else
Hyperstring = "http://" & Trim(xCell.Formula)
End If
ActiveSheet.Hyperlinks.Add Anchor:=xCell, Address:=Hyperstring
End If
i = i + 1
If i = 10000 Then Exit Sub
Nextxcell:
Next xCell
If Not CellsWithSpaces = "" Then
MsgBox ("Please remove spaces from the following cells:" & CellsWithSpaces)
End If
Application.ScreenUpdating = True
End Sub
For me I just copied the entire column which has the URLs in text format into another application (say Evernote), and when they were pasted there they became links, and then I just copied them back into Excel.
The only thing here is you need to make sure the data you copy back lines up with the rest of the columns.
Try this:
=HYPERLINK("mailto:"&A1, A1)
Replace A1 with your text of email address cell.
For anyone landing here with Excel 2016, you can simply highlight the column, then click the Hyperlink tab located on the Home ribbon in the Styles box.
Edit: Unfortunately, this only updates the cell style, not the function.
You can insert the formula =HYPERLINK(<your_cell>,<your_cell>) to the adjacent cell and drag it along all the way to the bottom. This will give you a column with all the links. Now, you can select your original column by clicking on the header, right-click, and select Hide.
If you copy the text contents into a new column and use:
=HYPERLINK("http://"&B10,B10)
on your original column. Then use the $ for the column so it looks like this:
=HYPERLINK("http://"&$B10,$B10)
That's the only way it worked for me on Excel 2010 on Windows 7. You can copy down the formula.
Put the URLs into an HTML table, load the HTML page into a browser, copy the contents of that page, paste into Excel. At this point the URLs are preserved as active links.
Solution was proposed on http://answers.microsoft.com/en-us/mac/forum/macoffice2008-macexcel/how-to-copy-and-paste-to-mac-excel-2008-a-list-of/c5fa2890-acf5-461d-adb5-32480855e11e by (Jim Gordon Mac MVP)[http://answers.microsoft.com/en-us/profile/75a2b744-a259-49bb-8eb1-7db61dae9e78]
I found that it worked.
I had these URLs:
https://twitter.com/keeseter/status/578350771235872768/photo/1
https://instagram.com/p/ys5ASPCDEV/
https://igcdn-photos-g-a.akamaihd.net/hphotos-ak-xfa1/t51.2885-15/10881854_329617847240910_1814142151_n.jpg
https://twitter.com/ranadotson/status/539485028712189952/photo/1
https://instagram.com/p/0OgdvyxMhW/
https://instagram.com/p/1nynTiiLSb/
I put them into an HTML file (links.html) like this:
<table>
<tr><td>https://twitter.com/keeseter/status/578350771235872768/photo/1</td></tr>
<tr><td>https://instagram.com/p/ys5ASPCDEV/</td></tr>
<tr><td>https://igcdn-photos-g-a.akamaihd.net/hphotos-ak-xfa1/t51.2885-15/10881854_329617847240910_1814142151_n.jpg</td></tr>
<tr><td>https://twitter.com/ranadotson/status/539485028712189952/photo/1</td></tr>
<tr><td>https://instagram.com/p/0OgdvyxMhW/</td></tr>
</table>
Then I loaded the links.html into my browser, copied, pasted into Excel, and the links were active.
Thank you Cassiopeia for code. I change his code to work with local addresses and made little changes to his conditions. I removed following conditions:
Change http:/ to file:///
Removed all type of white space conditions
Changed 10k cell range condition to 100k
Sub HyperAddForLocalLinks()
Dim CellsWithSpaces As String
'Converts each text hyperlink selected into a working hyperlink
Application.ScreenUpdating = False
Dim NotPresent As Integer
NotPresent = 0
For Each xCell In Selection
xCell.Formula = Trim(xCell.Formula)
If InStr(xCell.Formula, "file:///") <> 0 Then
Hyperstring = Trim(xCell.Formula)
Else
Hyperstring = "file:///" & Trim(xCell.Formula)
End If
ActiveSheet.Hyperlinks.Add Anchor:=xCell, Address:=Hyperstring
i = i + 1
If i = 100000 Then Exit Sub
Nextxcell:
Next xCell
Application.ScreenUpdating = True
End Sub
I had a list of numbers that feed into url's I want hotlinked.
For example I have Column A with question numbers (i.e., 2595692, 135171) and I want to turn these question numbers into hotlinks and to display only the question numbers.
So I built a text-only hyperlink pointing to Column A, and copied it down for all my question numbers:
="=HYPERLINK("&"""http""&"":"""&""&"&"&"""//stackoverflow.com/questions/"&A1&""""&","&A1&")"
Then I copy - paste value this column of text hyperlinks to another column.
You end up with a column of text that looks like the following:
=HYPERLINK("http"&":"&"//stackoverflow.com/questions/2595692",2595692)
Then I selected these pasted items and ran the F2Entry Macro that follows:
Sub F2Enter()
Dim cell As Range
Application.Calculation = xlCalculationManual
For Each cell In Selection
cell.Activate
cell = Trim(cell)
Next cell
Application.Calculation = xlCalculationAutomatic
EndSub
I then deleted the text entry column and Column A.
I ended up with a single column of hotlinked question numbers:
2595692
135171
etc.
Cheers
On Mac, a dead easy way to do it is select your entire spreadsheet in Excel, copy, launch Numbers, paste, then select all, copy, and paste back into Excel.
Easiest way here
Highlight the whole column
click ''insert''
click ''Hyperlink''
click ''place in this document''
click ok
thats all
The simplest way in Excel 2010:
Select the column with the URL text, then select Hyperlink Style from the Home tab.
All URLs in the column are now hyperlinks.
Also double clicking each cell at the end of the URL text and adding a blank or just enter will also produce a hyperlink. Similar to the way you have to create URL links in MS Outlook emails.
There is a very simple way to do this. Create one hyperlink, and then use the Format Painter to copy down the formatting. It will create a hyperlink for every item.