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 :- -
-
Private Sub Workbook_SheetChange(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:\Documents and Settings\Anup\Desktop\book1.txt" & 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,.Application.UserName
-
Print #Fnum, W.Name; vbTab; .Column; vbTab; .Row; vbTab; .Value; vbTab; Application.UserName; vbTab; Now(); vbTab
-
End With
-
Next
-
-
Set W = Nothing
-
-
Set C = Nothing
-
-
Close #Fnum
-
-
End Sub
-
5 1607
I'm not sure I understand. Every cell that's edited is going to have a Row and a Column that it exists in, so how do you plan to determine if it's a row edit instead of a column edit?
go thru the below example:-
this is the content of the file which is actually generated after change is made
AUDIT_PERSONALIZATION 1 104 5/21/2007 b 5/22/2007 5:50:01 PM
AUDIT_PERSONALIZATION 2 104 1 b 5/22/2007 5:50:01 PM
now i want this file to come up with header e.g
sheet name row column value date username
AUDIT_PERSONALIZATION 1 104 5/21/2007 b 5/22/2007 5:50:01 PM
AUDIT_PERSONALIZATION 2 104 1 b 5/22/2007 5:50:01 PM
Is there anyway??
Why not just use Notepad or something, and create the file with your headers there already. Then your code can just append to the file.
Or if your code creates the file, it can simply write out the header line before writing the first line of "log info".
If you need to check whether there's anything in the file yet, after you open it you can use the Lof() function to get the current length (zero if it's empty).
Why not just use Notepad or something, and create the file with your headers there already. Then your code can just append to the file.
Or if your code creates the file, it can simply write out the header line before writing the first line of "log info".
If you need to check whether there's anything in the file yet, after you open it you can use the Lof() function to get the current length (zero if it's empty).
I can't use a format of file since this reports are generated on daily basis.
i think your second idea is correct. Can u plz guide me the code for writing the header line.As i am not aware of the code.
Well, I don't know your circumstances very well, but it should be pretty simple, something like... - ' After opening the file for Append...
-
If Lof(FileNum) = 0 Then
-
Print #FileNum, "sheet name row column value date username"
-
End If
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Terry |
last post by:
Hi, I need some feedback.
We are converting to .Net and we are trying to decide on whether to use
VB.net or C#.net.
As far as our current systems, they will probably be rewritten in ASP.Net.
I...
|
by: Saga |
last post by:
Hi all, I just read the thread by the same name posted on Jun 15, 9:45 AM,
but
I am looking at it from a different point of view. I came across this
question in
terms of functionality. Are VB and...
|
by: Arsalan |
last post by:
Is there any advantage in C# over VB.NET ? Or the difference is only syntax
? Can anything done in C# which cannot be done in VB.NET?
|
by: Eric Wise |
last post by:
Does anyone work for companies that actually implement both VB and C#? I
know that you can do this in theory, I just find it hard to imagine that a
company would split its programming technologies...
|
by: Jim Hubbard |
last post by:
http://www.eweek.com/article2/0,1759,1774642,00.asp
|
by: D H |
last post by:
Hi,
Hi, I was looking for your opinion on VB.NET - its long-term
prospects, etc. Sorry this is vague, but it's not meant to be a troll.
It's a pro-VB.NET post actually.
I haven't used VB or...
|
by: clintonG |
last post by:
This is not about starting a fight but an observation that seems to be
proving itself on its own merit and is therefore simply a point of
conjecture.
I did not get serious about writing software...
|
by: John Smith |
last post by:
Can someone convert from C# into VB this line for me:
if (c is System.Web.UI.HtmlControls.HtmlForm)
|
by: Striker |
last post by:
I have never used VB, so sorry for the novice questions. I have a very
small app in vba that only uses excel as a place to put a button and some
code that I need to move to VB. Now it seems...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |