Hi all,
Below are the codes which i wrote to monitor changes in excel. Now i wanted to add Header for the text file which will be generated. LIke suppose if change is happend in the row. i wanted to give name of the hader as "ROW". In the text file.
if changes are happening in the column i wanted to Name it as column.Kindly help me??
below are the codes :-
[code=vb]
Private Sub Workbook_SheetC hange(ByVal Sh As Object, ByVal Target As Range)
Dim W As Worksheet
Set W = Sh
Dim C As Range
Dim Fnum As Long
Dim strFileName As String
strFileName = "C:\Documen ts and Settings\Anup\D esktop\book1.tx t" & Format(Now(), "yyyy-mm-dd" & ".Txt")
Fnum = FreeFile
Open strFileName For Append Access Read Write Lock Write As #Fnum
For Each C In Target.Cells
With C
'Debug.Print , W.Name, .Column, .Row, .Value, .Value2,.Applic ation.UserName
Print #Fnum, W.Name; vbTab; .Column; vbTab; .Row; vbTab; .Value; vbTab; Application.Use rName; vbTab; Now(); vbTab
End With
Next
Set W = Nothing
Set C = Nothing
Close #Fnum
End Sub
[/code]
Below are the codes which i wrote to monitor changes in excel. Now i wanted to add Header for the text file which will be generated. LIke suppose if change is happend in the row. i wanted to give name of the hader as "ROW". In the text file.
if changes are happening in the column i wanted to Name it as column.Kindly help me??
below are the codes :-
[code=vb]
Private Sub Workbook_SheetC hange(ByVal Sh As Object, ByVal Target As Range)
Dim W As Worksheet
Set W = Sh
Dim C As Range
Dim Fnum As Long
Dim strFileName As String
strFileName = "C:\Documen ts and Settings\Anup\D esktop\book1.tx t" & Format(Now(), "yyyy-mm-dd" & ".Txt")
Fnum = FreeFile
Open strFileName For Append Access Read Write Lock Write As #Fnum
For Each C In Target.Cells
With C
'Debug.Print , W.Name, .Column, .Row, .Value, .Value2,.Applic ation.UserName
Print #Fnum, W.Name; vbTab; .Column; vbTab; .Row; vbTab; .Value; vbTab; Application.Use rName; vbTab; Now(); vbTab
End With
Next
Set W = Nothing
Set C = Nothing
Close #Fnum
End Sub
[/code]
Comment