Reference the archives at:
http://www.mrexcel.com/archive/VBA/17448.html
How can I modify this sub to skip cells that are empty? I only want cells that are populated within the range to actually display the comment indicator, with the cell text transferred to the comment.
Ideally, I'd also like the text to be moved (not just copied) to the comment and leave an 'X' in the cell, in place of the text that was transferred to the comment, but I'll settle for the action above.
When adding a comment I check for an existing comment, if exist then delete and add new comment and some text in that cell. This works as long as the cell has an existing comment; other wise it advances to the "Else" where I thought I would be entering a comment and text in an empty cell. Why does my macro treat an empty cell as if it has a comment?
I am having trouble writing a macro to do the following. Someone had created a spreadsheet a while back that highlighted the cell green and inserted a comment with the person's name and date/time if they changed anything in that cell. The macro works great, but I need a macro to undo the changes.
I would like a macro that will remove all comments from the sheet and revert the cells back to their original color. Since the cells encompass many colors, at the very least, I would like the macro to remove the comments and make the cells the default shading (white).
I have a situation where textual comments are entered into a cell where the comments are supposed to begin with a date in mm/dd format. Some enter all 5 characters but some enter m / d in if appropriate to the date, e.g., 9/6 vs 09/06.
I'm trying to take the left 5 characters and compare that to the current date - 7 to ID aged comments and highlight that cell. I currently do this by populating a variable LastUpdate (dim as string) with the first 5 characters, then run this IF statement.
If LastUpdate < Date - 7 Then Range("O" & i).Select Selection = "Comments over 7 days old." End If
This works find except in situations where there is a zero for the first character after the "/", such as "11/05." The code doesn't properly calculate the date and assumes it's old. "11/5" works just fine. I thought I could try translating the variable into a proper date. I "borrowed" this formula from another post herein: =DATE(2012, MID(N12,1,FIND("/",N12)-1), MID(N12,FIND("/",N12)+1,2)). This works fine as a formula to translate the characters into a date but I don't know how to do this same thing in vba.
How would you prevent the copy/paste of cells that have comments?
Also, how would you allow cells with comments to be copied and pasted without pasting the comments?
I also have an aside question about the forum advanced search. When searching for multiple search words, how would you type the search to include all words, for example, "prevent" & "paste" & "comments".
I do not have any VBA knowledge. However, teach/show me how to write a macro to convert each new record (with a date range) into individual records for each day in that date range. It might take me a long time to learn from you but I really don't mind trying and putting in the effort. My description of the idea is shown below.
The intention is for new records to be added each time a staff/member has a new travel trip. Each new record = new row added below the last record previously added. DateRangeQ_1.png
With the macro, I hope to be able to add each new record to a separate list. This separate list shows those travel records by each individual date and staff/member name. The dates do not need to be in chronological order. DateRangeQ_2.png
So if Mary Jane enters a new business trip to Egypt for 15th Dec to 17th Dec, she will enter a new record in row 9, click the macro button and the macro will generate 3 new records in rows 31, 32 and 33 (one row for one date in the trip).
First my goal is to sum a row and column. For example i want the sum of row 1 a to row 1 g. However, I'm using a loop for an automated macro. So i want to be able to say something like cells(1, count), so during the loop count goes from 1 to 7 representing the letters in the alphabet. But I'm not sure how to do so.
Secound, in my vba script to pull information from specific pages i say "sheet1.activate" how can i had the sheet switching during the process to speed up the calculation? and last but not least,
If Cells(1, locd) = "2008" Then
When i run my script, i get a runtime error 1004 application-defined or object defined error. The weird thing is, i can move what line it is on and then the macro will run ONCE and then it breaks again with the same error for that specific piece of code.
I need to identify any cells in a range that do not contain text then colour and comment them. I intended to use the following code, however it doesn't work as I expected it to.
With rRange.SpecialCells(xlCellTypeBlanks) If .Count > 0 Then .Interior.ColorIndex = zErrorColour .AddComment "This cell must contain a value" End If End With
The blanks cells are coloured OK but only the first blank cell gets a comment. Is there a reason why I can't add comments to all the cells in the range? And if there is a good reason, then I guess I'm going to have to write a loop to add the comments.
I received assistance from NBVC for combining data from two cells. Post http://www.excelforum.com/showthread.php?p=2135144. I need to convert the formula into macro code. I thought I would be able to convert it on my own, but running into some troubles with run time errors. Here is the Excel formula, which is working fine.
trying to speed up run time of legacy app, learned that setting a range = an array is a better strategy than manipulating cells one by one, no problem with this approach on cell values but getting errors trying same approach with comments as follows:
I am trying to add comments in a selection of cells and where there is a value then the comment should show the formula value of the cell ie if the formula in cell A1 is = 9 + 10 then the comment should show this. This I have got to work, but if I have a comment already the macro fails and I have tried to get round this but I am not clever enough.
I am trying to find out if it is possible to do the following
I have an excel workbook with comments in a number of worksheets. I have created a macro so I can list the comments and the value of the cells with comments. The macro creates a new worksheet and list the comments and value this great but I can only get it to create the comments from the sheet which is active. Is there a way of getting all the comment and cell value from all the worksheet (the entire workbook)
this is the code for the macro
Sub shoppinglist() Application. ScreenUpdating = False
Dim commrange As Range Dim mycell As Range Dim curwks As Worksheet Dim newwks As Worksheet Dim i As Long
Set curwks = ActiveSheet
On Error Resume Next Set commrange = curwks.Cells _ .SpecialCells(xlCellTypeComments) On Error Goto 0
If commrange Is Nothing Then MsgBox "no comments found" Exit Sub End If ...
1)After comparison and no difference between the cells 1.1) If the cell selected is blank then there will not be any color 1.2) Else the cell will be colored GREEN
2)After comparison and there is difference between the cells 2.1) Cells wiill be colored RED
However, my code seems to be unable to execute (1.1) . Pls help to see if there's any thing wrong with my code
For K = 1 To 31 For L = 1 To 29 'Do a comparison of the cells If StrComp(Array_compare(A, 1), Array_compare(A, 2)) = 0 Then
If IsEmpty(Array_compare(A, 1)) Then Sheets(3).Select Cells(K, L) = Array_compare(A, 1)
I have a cell comment on a series of columns and want to show only one column at a time. For this reason I hide the ones not used, but the cellcomment doesnt move and is still at the original place. How I move the comment when the original colums between are hidden ?
I have a standard laid out spreadsheet, but in column C, D and E, there are comments in each cell which are filled with a lot of text. I would like to set a macro so that whenever an 'a' is in column A, the comments for that row are shown/hidden (the 'a' being a tick symbol in Webdings). So if I place an 'a' in A4 and A23, and click a show/hide button, it causes the comments in C4, D4, E4; C23, D23 and E23 to be displayed, and when it is clicked again (or it could be a separate button), they disappear. If no row has an 'a' in the A column, then the button has no action. I have recorded a Macro of me showing and hiding comments, but of course that is for a specific row.
I'd like to know how to have the comment feature without the red triange on cells with comments. I didn't want to use data validation comments because I want the hover feature.
I try to edit comments in cells of a certain column and nothing happens. I am able to edit other comments throughout the spreadsheet, but when I select "edit comments" for these particular cells, no edit box is displayed for editing. It worked fine a couple of weeks ago.
I want to add comments to all the 1 value cells by selecting all 1 by shift + ctl +down
I can put same comments to all the cells?
If you want to have the same comment applied on many cells you could apply it to a single cell, then use the copy and paste special tool bar commands (under Edit) In Paste Special select "Comments" but value is going of that cell.
I noticed that I have several (@200) comments that when visible displays Cell X Commented by (my work user number) in the lower left corner of the excel window. I'm not sure how to change this so its the company name instead of my work number. I'd be using a loop to go through each comment but need help with the line that would change this part.
I have a report where, month in month out, i have to append columns on the right, to give a Year to date figure. Now there are many rows with different numbers but one of the columns is call [NOTES]. This is where the user can provide commentry on the weekly figures.
Now whats getting annoying is i have to copy this commentry and then create a comments box then paste the text in there and finally, hide the comment.
So what i want to be able to do is be able to Copy the cell, then, have a right click menu button saying "Paste As Comment", so it paste the selected cells contents into a comment and hides it.
I have a worksheet where some cells contain a comment. I don't know beforehand how many of those cells are present, nor their address. I want to write a macro that stores the values of only the cells that contain a comment into an array (of course the size of the array is not known beforehand). This should be done by scanning through those special cells in a given order (by rows, by columns, whatever).
Among many attempts to insert and autosize a comment using VBA manually, which errored, i recorded the following bit. When running the macro, it does format the cell - text, not the comment - text and errors in the line highlighted in red.
Range("A14").Select Range("A14").AddComment Range("A14").Comment.Visible = False Range("A14").Comment.Text Text:="Ladida" With Selection .HorizontalAlignment = xlLeft .VerticalAlignment = xlTop .ReadingOrder = xlContext .Orientation = xlHorizontal .AutoSize = True End With
I just want to add
.AutoSize = True
or something to that effect to the bit below. Any suggestions?
I am a novice user and not very familiar with Macros or VBA. I took a macro I found on contextures and got it to resize comments that already exist. However, I am trying to get it to also create the comment (with no content) if the comment does not already exist, and then resize it. This is what I have so far:
Code: Sub ResizeCommentsInSelection() Dim mycell As Range Dim myRng As Range Dim lArea As Long Set myRng = Selection
1st - Need a macro to change a range of cells colours based on a single cell having a value greater than 0.001. ie. cells A1 - G1 need to change to grey based on cell F1 having a value greater than 0.001 entered in it?
2nd - Also a macro for deleting the text contents of cell C1 based on cell F1 having a value greater than 0.001. Therefor if cell F1 has a number greater than 0.001 it changes the colour of celss A1 - G1 and also deletes the text in cell C1?
My searches have not produced anything that I could apply to this situation.
I'm trying to write VBA that would:
1. Search a Workbook for Dynamic Ranges.
2. When a Dynamic Range is found the code would:
A. Determine the current coordinates for the range. B. Change the "Refers To" value From "=OFFSET...." To "=Worksheet_Name $Column$Row:$Column$Row"
3. Save Changes.
4. Close File.
My apologies but I have very little experience in writing VBA. I understand about variables, arguments, and IF/THEN but just enough to use functions within Excel.
I am trying to create a macro such that in a given column (AB 0 -100), if the cell entry is "1", then another cell in the same row will be copied (C) and pasted to a third column (F).
All of the entries in column AB are 0 or 1.
So, for example, if AB23 = 1, the contents of C23 are copied, and pasted in to F23.
If AB24 = 0, nothing happens.
Code:
Dim i As Integer For i = 1 To 100 If Range("AB" & i).Value = 1 Then Range("C" & i).Select Selection.Copy