VBA Code to add comment to changed cell [duplicate] - vba

This question already has an answer here:
Excel: Add comment author using vba
(1 answer)
Closed 8 years ago.
I need to add a comment with original data to cell where data is changed.
Ex: 4 of 7 gets changed to 3 of 7 in a cell. I need the comment to show 4 of 7 so I can see what the original data was.
Is there a macro that can be written to automatically insert a comment with original data to all cells that have been changed?

Say you are working with Cell A1
Before you change the value of Cell A1, store it in a variable myVal, then write something along the following lines:
Range("A1").AddComment
Range("A1").Comment.Text Text:= myVal

Related

Use data_only=True when you load your workbook. (For example, workbook = openpyxl.load_workbook("yourxlsx.xlsx", data_only=True)) [duplicate]

This question already has answers here:
Python openpyxl data_only=True returning None
(7 answers)
Closed 1 year ago.
I am not able to print the computed cell value with this option. it is printing the formula instead of cell value.. can someone please help me on this.!!!!!!!!!!!!!!!!
sheet['L3'] = '=COUNTIF(B1:B431,"Resolved")'
now I want to print the L3 cell value to the screen
Python openpyxl data_only=True returning None
According the this thread, the formula needs to be evaluated by Excel before having its value cached.

Excel cells matching in VBA [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I want to use a number in a cell of my main excel sheet and use it to search for a specific line in another excel file that start with this number. After, the program needs to use the value of a specific cell in this line for a cell in my main excel sheet.
EX : value of the first cell in my sheet : 6.02 . Now the program need to find this value in a column of another file. The line that start with 6.02 contain a cell with the value dog. The value dog need to go inside a cell next to the first one that contain 6.02.
I need your help because I know nothing about VBA. I'm starting today!
Thank you very much !!
You can accomplish this with a VLOOKUP between two books. The guts of the equation are below. You wont actually type in the '[book2]SheetName' portion, this will need to reflect the name of your other workbook and the sheet that you are looking at within that book.
A2 = Look up value (in your example 6.02)
X1 = Column the return value is (in your example "dog")
X2 = Column Index Number (Of if you are not starting from A it represents the (Index Col of Value - Index of Look up Value) + 1
=VLOOKUP(A2,'[Book2]SheetName'!$A$X1,X2,0)

How To Identify Cell Address VBA [duplicate]

This question already has answers here:
Find last used cell in Excel VBA
(14 answers)
Closed 5 years ago.
How do I find the last line/Row of an edited document meaning new information will be added to the document without my knowledge and I still need to be able to identify its address. VBA
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
If you don't need VBA, then press Ctrl + Down Arrow in a column with continuous rows to bring you to the last row

Automatic excel cell fill up from another sheet [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Here's the situation:
I have two excel sheets.
The first sheet contains a table of product codes and product descriptions (Two columns A and B).
I have a second sheet where someone is supposed to enter the product code and automatically have the next cell fill up with the product description and the cell next to it with the time.
I was wondering if that's do-able without VBA? If so, can someone give me start.
Best,
You could have the first cell that you want to auto fill have an IF statement, where if the cell has no value, nothing happens, and anything other than that gets a calculation.
Using A2:B100 as a Range if you have a header Row. Adjust to your own needs, of course.
IF FUNCTION
'IF (condition, result if true, result if false)'
VLOOKUP FUNCTION
'VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)'
=If($A1 = "", "", VLOOKUP(A1,Sheet1!$A$2:$B$100,2))
The next cell over would have something similar:
=IF($A1 = "", "", NOW())
This will get you the time. You will also have to have the cell format set to Time.
There is a problem with that. The screenshot below illustrates it.
It will just keep refreshing with the current time over and over. I would use a bit of VBA to solve that by setting the value property instead of a formula.
Sheets("Sheet2").Cells(row,col).Value = Now()
You could copy and paste the value into another cell. Just the value. Not the formula.
Or you could check out this article: about generating Time Stamps.
edit: included VBA solution

Macro to Transfer Specific Table Content in MS Word 2007 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have around 50 word documents in an old format which I need to convert to a new format. I was thinking of having a new format template and copying needed numbered fields from the old format into the new format using a macro, and finally saving this new document.
I have numbered fields from 1 to 6 in the old format where some fields are in the header. I need these fields in the new format where the sequence is different.
I am a absolute beginner in macros and need to submit this tomorrow so would appreciate any help or advise urgently.
Word documents download links are mentioned below:
OLD FORMAT : http://www.scribd.com/R0cKyMan/d/90470134-Old-Format
NEW FORMAT : http://www.scribd.com/R0cKyMan/d/90473107-New-Format
So can u help me out with copy header fields. Thanks – R0cKy 3 mins ago
The tables in the Header have to be accessed in a different way.
When a table is in the body, you can use it like this
ActiveDocument.Tables(1).Cell(1, 1).Select
Selection.Copy
But to access the table which is in the Header you have to access the Section in which the Header is. In your case the table is in wdHeaderFooterPrimary
Try this
Option Explicit
Sub Sample()
'~~> Copies the 2nd Cell in the first row of a table which is in the Header
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Tables(1).Cell(1, 2).Select
Selection.Copy
'~~> Pastes it in say 1st cell in Row 1 of a table which is in the body
ActiveDocument.Tables(1).Cell(2, 3).Select
Selection.PasteAndFormat (wdPasteDefault)
End Sub
Hope this gets you started.