Code for Excel Macros- Editing the Notepad

Himaja

Board Regular
Joined
Oct 14, 2013
Messages
62
Can any one help in providing the code for the below scenario:

I will browse for an excel file which has columns like: Line Number, Length, Value
Using Excel Macros, I have to open an existing text file, make the changes in it with the values in the "value" column of Excel from Line Number and Column no. specified in the excel.

Save the modified text file in a particular path
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Welcome to MrExcel.

You don't need to edit in Notepad. Open the text file in Excel, make the changes and save then close it.
 
Upvote 0
Welcome to MrExcel.

You don't need to edit in Notepad. Open the text file in Excel, make the changes and save then close it.


I think you havent understood the requirement.

My Excel will have only have data to edit the note pad contents from a particular Line Number and Column number and the value to be replaced.

Code has to take the info from the Excel, and open Text file (which has some data already present) and need to replace the value with the value from Excel at the particular position and save the text file.

Text file is a fixed length file
 
Upvote 0
You can open a text file in Excel. You don't need to open it in Notepad. Try it - choose File|Open, change the file type to Text files, browse for the file and click OK.
 
Upvote 0
I understand that, but if you want help in editing the data you will need to be more specific about:

make the changes in it with the values in the "value" column of Excel from Line Number and Column no. specified in the excel.

Save the modified text file in a particular path

Where can the changes to be found and what is the "particular path"?
 
Upvote 0
I understand that, but if you want help in editing the data you will need to be more specific about:



Where can the changes to be found and what is the "particular path"?

I will have a "Good_File.txt" (my Text file which has already some data), which I will browse from my code.
Also I will have an "Input.xls" file (which has LineNo., Col No.,Value (3 columns) that are to be replaced in the text file) which I will browse from my code.

Now my requirement is:
When I browse these 2 files (text, Excel) and click on "Go" button, code should do the follwing things:
1. From the excel, it should take the value from the "value" column and add it in the text file at the particular position (the position is mentioned in "Line No" and "Col No." columns in the excel)
2. Once after replacing the existing content in the text file with the content mentioned in the Excel, the text file should be saved in a path (this path may be hard coded in the code)
3. Like wise the above 2 steps are to be repeated based on number of rows in the excel and that many text files are to be created and placed in the path.


Sample Excel:

Line No. Col No. Value
2 36 20121026
3 53 HimajaMadineni

Sample Text File:

HDRAutomatic Data Processing, Inc. 201308012013072620130731
POL123456789WC WC12345-01 2012102620131026The Office Cast 11111 Any Avenue AnyTown NJ07940 9737123000corinne.summers@adp.com N2A
CLS123456789WC WC12345-01 2012102620131026 Knope, Leslie 000000010 MD958601ABARBER SHOP N0 00000000012320000000000001590020130707201307202013080120130726018 777000012426 00049
CLS123456789WC WC12345-01 2012102620131026 Lemon, Elizabeth 000000011 MD958601ABARBER SHOP N0 00000000013950000000000000000020130707201307202013080120130726018 777000012426 00049
CLS123456789WC WC12345-01 2012102620131026 Maroney, Jenna 000000014 MD958601ABARBER SHOP N0 00000000010370000000000002360020130707201307202013080120130726018 777000012426 00049
CLS123456789WC WC12345-01 2012102620131026 Dwyer, Andrew 000000019 MD958601ABARBER SHOP N0 00000000011485000000000001400020130707201307202013080120130726018 777000012426 00049
 
Upvote 0
My sample Text file shows correctly, Line 2 and Col 36 have 20121026. In Text File Col is the Position of Cursor at "Ln #, Col #"


-- removed inline image ---
 
Upvote 0
In your sample data 20121026 is at position 27 not 36 on line 2. What do you want to do with that text? I don't see HimajaMadineni at all on line 3.
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,999
Members
448,541
Latest member
iparraguirre89

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top