using notepad with excel

Dennis

New Member
Joined
Apr 27, 2002
Messages
4
Hey

Im new to using excel and visual basic and I want to create a macro, which will collect information from a sheet in excel paste it to notepad and save it in notepad. I would also like it not to replace the previous time it saved notepad.

Thanks if anyone can help
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi colo thanks for the help it works but it means I will have to delete the previous document that has been saved. Is there a way to call the notepad document a different name each time the macro is run like 1, 2, 3...or something like that. Thanks for the help
 
Upvote 0
Hi Dennis. May I ask you a question?
The cells where you want to save are always same?
If so, I would like to recommend to use "open statement" to you.

But the cells what you want to save are different for each times,
I would like to recommend to use another way (see following code).<pre>
Sub Test()
Dim arrBuf(), i As Long, c As Integer, shAct As Worksheet
Dim strFName As String 'aFile Name :Full path
With Application
.ScreenUpdating = False
.DisplayAlerts = False
'Copy to clipbord
Set shAct = ActiveSheet
strFName = Application.GetOpenFilename("Textfile(*.txt),*.txt")
If strFName = "False" Then Exit Sub
c = 256
ReDim arrBuf(1 To c)
For i = 1 To c 'Loop
'A reading format is limited to a character sequence.
arrBuf(i) = Array(i, 2)
Next i
delimt = "," 'Or Chr(9) which mean Tab
On Error GoTo READY_OPENED
Workbooks.OpenText FileName:=strFName, _
StartRow:=1, _
DataType:=xlDelimited, _
Other:=True, _
OtherChar:=delimt, _
FieldInfo:=arrBuf

shAct.Range("A1").CurrentRegion.Copy Range("A65536").End(xlUp).Offset(1)
With ActiveWorkbook
.SaveAs FileName:=strFName, FileFormat:=xlText
.Close False
End With
.DisplayAlerts = True
.ScreenUpdating = True
End With
Exit Sub
READY_OPENED:
MsgBox "The file is already opened."
End Sub</pre>

_________________
With regards,
Colo :)<MARQUEE scrollamount=8 behavior=alternate>
pa_kas.gif
</MARQUEE>
This message was edited by Colo on 2002-04-29 18:17
This message was edited by Colo on 2002-04-29 20:54
This message was edited by Colo on 2002-04-30 19:42
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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