Replace Text from Excel Sheet to Notepad
In this post we will show how to modify data in the Notepad from the Excel spreadsheet. We will write one macro here to do our job. I am sure you must have done manual copy-paste from excel to notepad many times. This macro will not only save your time but also make sure that there is no error that you could do manually.
There is an excel sheet with the two columns, Employee ID and Employee Name. We also have a notepad file which has only the Employee ID of the employee.
Our task is to replace the Employee Id in the notepad with their corresponding Employee Name. The Employee Name needs to be picked from the excel file.
Our Macro will one by one go through each of the Employee Id in the excel sheet and search it in the notepad file, if Employee Id is found in the notepad it will be replaced by the Employee Name which is present right next to the Employee Id
Backup of the Notepad file
As a safety measure a backup of the Notepad file is created and saved in a folder with the name Backup_ExcelSheetFileName. The Backup Notepad file will have Backup_ Prefixed to original name and each time the Macro is run the old Backup file will be over written.
How to use this Macro
1. Lets assume the name of your excel sheet is replace_text_notepad.xls and the name of your notepad file is replace_text_notepad.txt
2. The data in the Excel sheet and Notepad file is same as shown in the examples attached. Of course your data could be different.
NOTE: The important point to note here is that the Employee Id should be present in the first column starting from Cell A2 and the corresponding Employee Name should be present in second column starting from Cell B2.
3. Press ALT + F11 to open the Visual Basic Editor
4. Create a Module and copy-past the below code.
5. Again come back to the Excel sheet and press ALT + F8 and run the Macro Macro_Replace_From_Excel_To_Notepad
6. Enter the Notepad file name. In our case the name is replace_text_notepad.txt
Click OK to Run the Macro. The Notepad file should be present in the same folder where the excel sheet is located.
If you enter wrong File name here an error is thrown.
7. Now the task has been executed successfully and the Notepad File is also processed. You can open the Notepad and see the changes.
8. After the execution of the Macro you can see that a new folder named replace_text_notepad.xls (Folder name is same as the Excel Sheet name with .xls extension) has been created which has the backup of the original Notepad file with the name Backup_replace_text_notepad.txt
Sub Macro_Replace_From_Excel_To_Notepad() Dim NotepadPath, NotepadFileName As String ''Take the Text file name from the user NotepadFileName = InputBox("Enter the File Name of the Notepad file. File should be " & _ "present in the same folder (For example: FileName.txt)") If NotepadFileName = vbNullString Then Exit Sub End If NotepadPath = ActiveWorkbook.path & "\" & NotepadFileName ' This for loop should only be called only if the Notepad file is found If Not Len(Dir(NotepadPath)) = 0 Then ' Backup folder is created is not already created Dim BackupPath As Variant BackupPath = ActiveWorkbook.path & "\" & "Backup_" & ActiveWorkbook.Name If Not Len(Dir(BackupPath, vbDirectory)) = 0 Then 'Do nothing Else MkDir (BackupPath) End If ' Text is file is copied to the Backup folder FileCopy NotepadPath, BackupPath & "\" & "Backup_" & NotepadFileName 'Open the Text file in Notepad value = Shell("C:\windows\system32\notepad.exe " & NotepadPath, vbNormalFocus) ' space after \notepad.exe_ and " is imp ActiveSheet.Select ' Select the Sheet Range("a2").Select For Each cell In Range(Selection, Selection.End(xlDown)) value = OpenReplace(cell.value, cell.Offset(0, 1).value) ' Call OpenReplace function Next cell SendKeys "^s" 'CTRL + s (Save) SendKeys "%{F4}~" 'ALT + F4 (Close) Else MsgBox "File not found" End If Range("a2").Select Range(Selection, Selection.End(xlDown)).Select End Sub Function OpenReplace(vText As Variant, vReplace As Variant) ' This function will open the notepad file and perform ' replace all function by sending keyboard actions SendKeys "^h" 'CTRL + H (Replace) SendKeys vText 'SHIFT + 2 (") SendKeys "{TAB}" SendKeys vReplace SendKeys "%a" 'ALT + A (Replace All) SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}" 'TAB x6 (to get to Cancel button) SendKeys "~" 'ENTER (press on Cancel button) End Function
Have fun!







xxxxxxxxxxx
The first and the most important task is to get the Cabal Online hacks, As soon as you play this game, you will spend time thinking deeply Cabal Online l guild, how to get the Cabal Online quest, quickly and easily Cabal Online forums, Then sell it to get the Cabal Online cheats.
replica watch
rently the Vacheron Constantin Kalla Lune sale hottest selling handbags on Rado replica watches the tout. sign places Longines Heritage sale to bonanza tone imitations are www.goodbags.org, considering replica watches they mention select the Rado Ceramica Black Mens Watch R21347162 watch tops imitations further guarantee breitling replica watches your alleviation. This online watches replica Anya HindarMarch icon Handbags watches replica fare is recognized to watches replica copy exclusive of the boss when live comes to replicas handbags purchasing the chief type designer replica handbags imitations of the hot replica handbag agname name Anya HindarMarch handbags. No isolated commit replica tiffany jewelry surpassingly distinguish the discongruity chanel earrings (including you) when you replica tiffany jewelry occupancy an imitafake Designer Style Silver CZ Chain of Hearts Bracelet
fake Blue Topaz Sterling Silver CZ Cocktail Ring
Sterling Silver Classic Pink CZ Princess Cut Promise Ring outlet
replica Louis Vuitton
replica Louis Vuitton Handbags
fake Louis Vuitton Handbags
Louis Vuitton replica Handbags
lv handbags
replica lv handbags
fake lv handbags
lv replica handbags
BURBERRY Handabgs replica
BURBERRY Handabgs
replica BURBERRY Handabgs
fake BURBERRY Handabgs
BURBERRY replica Handabgs
dropshippingwatch
replica Fendi Watches
fake Fendi Watches
Ferrari Watches
replica Ferrari Watches
Gucci 'Babouska' Medium
Gucci 'Babouska' Medium Shoulder Bag
Gucci 'Babouska' Medium Shoulder Bag
Gucci 'Babouska' Medium Top Handle Bag
Gucci 'Babouska' Medium Top Handle Bag
Gucci 'Babouska' Medium Top Handle Bag
Gucci 'Babouska' Medium Tote
Gucci 'Babouska' Medium Tote
Gucci 'Babouska' Medium Tote
Gucci 'Babouska' Medium Tote
Gucci 'Babouska' Medium Tote
dropshippingwatch
fake Oris Watches
Panerai Watches
replica Panerai Watches
fake Panerai Watches
Parmigiani Watches
replica Parmigiani Watches
fake Parmigiani Watches
GrandFantasia Gold
Gamers ought to know Grand Fantasia money if they really like to play this game. All gamers want to buy Grand Fantasia Gold to promote their character level easily, more Grand Fantasia Gold and GrandFantasia Gold they own, more items they can buy in game. While we provide you cheap Grand Fantasia Gold, surely you can get them at cheap prices.
Dungeon Fighter gold brings
Dungeon Fighter gold brings funny and happy time to players! Dungeon Fighter Online gold is very important for players. cheap Dungeon Fighter gold can make our character level up quickly. Players know it is hard to farm Dungeon Fighter money, so they would like buy Dungeon Fighter gold.
If you like using
If you like usingluminary gold to play which needs usebuy luminary gold, you can borrowcheap luminary gold from friends. You can buyluminary online gold,and than you useluminary money to continue the game
beautifull ugg
classic ugg boots
ugg boots sale
discount ugg boots
ugg classic boots
cheapest NFL jerseys
nfl all star jerseys
nfl jerseys
all star nfl
replica handbags
wholesale handbags
replica designer handbag
ugg boots online
ugg classic cardy
purple ugg
ugg sale
ugg australia sale
ugg ladies boots
cheap ugg boots
GrandFantasia Gold
You should know Grand Fantasia money if you play this game. I can say so: each gamer want to buy Grand Fantasia Gold to promote their character level easily, more Grand Fantasia Gold and GrandFantasia Gold they own, more items they can buy in game. While we provide you cheap Grand Fantasia Gold, surely you can get them at cheap prices.
ed hardy online
Exquisite design, superior material, exquisite craft. ed hardy online Close to her heart, the most perfect expression of your love.
Money gayweather loves
Money gayweather loves moneyuggs online Pac-Manny running shoes0oz gloves?
ugg boots on saleandsaying there
uggs onlineand
ugg sale
andnike outlet
replica watches
Rolex Submariner Tiffany & Co Vintage Edition-Green Nylon Strap
Rolex Submariner Tiffany & Co Vintage Edition-Gray Nylon Strap
Rolex Submariner Cartier Automatic with Black Bezel and Dial Vintage Version-Nylon Strap
Rolex Submariner Cartier Automatic with Black Bezel and Dial Vintage Version-Gray Nylon Strap
Rolex Submariner Cartier Automatic with Black Bezel and Dial Vintage Version-Black Nylon Strap
Rolex Submariner Cartier Automatic with Black Bezel and Dial Vintage Version-Green Nylon Strap
Rolex Submariner Tiffany & Co Automatic with Black Bezel and Dial Vintage Version-Nylon Strap
Louis Vuitton
Louis Vuitton Handbags
replica Louis Vuitton Handbags
fake Louis Vuitton Handbags
Louis Vuitton replica Handbags
lv handbags
replica lv handbags
fake lv handbags
lv replica handbags
Balenciaga Handbags
replica Balenciaga Handbags
fake Balenciaga Handbags
Balenciaga replica Handbags
BURBERRY Handabgs
replica BURBERRY Handabgs
fake BURBERRY Handabgs
BURBERRY replica Handabgs
Chanel Handbags
replica Chanel Handbags
chanel bags
GUCCI Handbags
GUCCI Replica Handbags
replica GUCCI Handbags
fake GUCCI Handbags
Hermes Handbags
reply
I think, standing in my personalugg boots for cheap view,
this article are very nice . In buy ugg bootsthis article,
I learned the knowledge that will good for myself. Thanks tougg bootsthe author of this article. Can read your article is
my lucky.
Dhonyobad...
Dhonyobad...
Very nice post! - useful to me in another project that I am doin
Good job!
Post new comment