Copy “Comments” using VBA, with a twist.

julhs

Active Member
Joined
Dec 3, 2018
Messages
476
Office Version
  1. 2010
Platform
  1. Windows
Have a large “Input Section” (16 Cols & 500-700 Rows) that has comments scattered throughout it, currently my “Analysis Section” only contains values taken from the “Input Section” using {=IF(SUMPRODUCT,ROWS,INDEX,SMALL………)}

My understanding is that I can’t use a formula to get the “Comments” from the “Input Section” into the corresponding cell in the “Analysis Section”.

What I want to do is get the Values & Comments into the Analysis Section, presently I have to copy/paste "Comments" individually.

Is there a way to do this retrospect fully with VBA from a Command button?
P.S "Comments" dont seem to be appearing on XL2BB, cells with "Fill colour" are ones with Comments
Accounts 2016 - 2019 Final Currant.xlsm
ABCDEFGHIJKLMN
1
2CASH BOOK
3DEBITS
4DateInvoice #Payment Method ListPayment Details ListBank & CashRentPowerMotoring Expenses Stock & MaterialsOffice
5
6Jul-05gs0370Direct DebitRent250.00250.00INPUT SECTION All details etc on left are Enterd via a USERFORM, including the comments. It finds the next empty Row & pastes in Userform values, then inserts a new blank row and formats it
7Jul-10gs0375Direct DebitEDF35.0035.00
8Jul-15gs0380Debit CardMicks Garage50.0050.00
9Jul-20gs0385Debit CardHalfords20.0020.00
10Jan-21gs0390Debit CardSouthern Building Supplies31.0031.00
11Jul-22gs0415Debit CardAmazon42.0042.00
12Jul-24gs0433PayPalDirect Stationary Supplies10.0010.00
13Aug-05gs0450Direct DebitRent275.00275.00
14Aug-10gs0460Debit CardWessex Steel40.0040.00
15Aug-10gs0462Direct DebitEDF50.0050.00
16
17Totals803.00525.0085.0070.0071.0052.00
18
19
20ANALYSIS SECTION RentEDFMicks GarageHalfordsSouthern Building SuppliesWessex SteelDirect Stationary SuppliesAmazon
21This section lists all the entries for individual supplier using SUMPRODUCT,ROWS,INDEX,SMALL. It does get bumped down as rows are added above250.0035.0050.0020.0031.0040.0010.0042.00
22275.0050.00      
23
24
25This is what I would like the desired outcome to beRentEDFMicks GarageHalfordsSouthern Building SuppliesWessex SteelDirect Stationary SuppliesAmazon
26250.0035.0050.0020.0031.0040.0010.0042.00
27275.0050.00
Testing (2)
Cell Formulas
RangeFormula
F17:K17F17=SUM(F6:F15)
G21:N22G21=IF(SUMPRODUCT(--($E$5:$E$15=G$20))>=ROWS(G$21:G21),INDEX($F$5:$F$15,SMALL(IF($E$5:$E$15=G$20,ROW($E$5:$E$15)-ROW($E$5)+1),ROWS(G$21:G21))),"")
Press CTRL+SHIFT+ENTER to enter array formulas.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Did you consider copy (from Micks's to EDF, I guess) then paste special>All>transpose?
Your target columns would have to be in the same order as your copied rows of course. I tried that and the comments were pasted. A lot easier than code?
 
Upvote 0
Thanks for reply Micron.
Entries in “Input section” will be in utterly random pattern, the “Analysis Section” has fixed Columns, but Row # will change due to being bumped down by the “Input Section”
 
Upvote 0
Does row# matter when copying/pasting? As for the randomness I presume you mean the order of things like the cells from Mick's to Rent? When you copy/paste, those cells become headers. So input
1671379056357.png

with output as
1671379085382.png

Sorry if I'm not following why that can't work. At the very least, I suppose you could go through the motions while recording a macro and get some clue as to the code you'd need if that's the route you need to take. BTW, not sure what those little red triangles are in your analysis section pic. They don't look like they represent errors, notes or threaded comments. The purple ones I show are threaded comments, which do paste into the new cells.
 
Upvote 0
For some reason XL2BB didn’t upload/show ANY Comments on the Mini Sheet that are on my ACTUAL sheet, had to resort to “Fill Colour” luminous green to indicate which cells had Comments. Ordinary “Comments” are red triangle in cells top right corner, SOME of the cells you fixed with purple triangle DO have “Comments”, but not all.

Just so we on the same lines:

This is an Accounts spreadsheet
Entries in “Input Section” are in random order (so the date/order is based on the date the Debit is made, irrespective of supplier name order)

I’m not using Copy/Paste FROM “Input section” to “Analysis Section”, the “Analysis Section” is using a formula {=IF(SUMPRODUCT,ROWS,INDEX,SMALL………)}
to pull the figures from the “Input Section” and list them under the Individual Suppliers, ie Rent,EDF,Micks Garage etc,

The “Analysis Section” has fixed headers.

What currently happens is, IF ANY entry in Col E matches the cell value in eg G20 (Rent), it pulls value from F20 and THAT value is placed it in the next blank cell under “Rent”, BUT WITHOUT the “Comment.”

What I’m trying do is pull FROM the “Input Section” the “Value” and the “Comment” from ie F13(Rent) into the next blank row under ie Rent

Everything I have posted works fine just to pull values from “Input Section” into “Analysis Section”, but I want to pull “Comments” at the time as well,

If formula option is off the table then maybe use VBA to get the “Comments” from Col F to relavant cells in G26:N27

I do pray this has made things clearer as opposed to more confusion!!!
 
Upvote 0
Sorry if I seemed to be pushing the transpose thing too much. It's just that without knowing how it all works it just seemed far simpler. I bet it can be done with vba. I have to sign off for a bit, but in the meantime, if you search posts I've made in the last 3 to 5 days, there have been at least two threads where I and others were dealing with notes (formerly known as comments) and "comments" (now called ThreadedComments I believe). Perhaps there is something in those that would get you started on code.
Here's one: Copying and Pasting CommentThreaded

The other also started by same OP as that one.
 
Upvote 0
Got side tracked and Message edit timed out.
Rephraseing/edit of above.

For some reason XL2BB didn’t upload/show ANY Comments on the Mini Sheet that are on my ACTUAL sheet, had to resort to “Fill Colour” luminous green to indicate which cells had Comments. Ordinary “Comments” are red triangle in cells top right corner; SOME of the cells you fixed with purple triangle DO have “Comments”, but not all.

Just so we on the same lines:
This is an Accounts spreadsheet
Entries in “Input Section” are in random order (so the date is when Debit is made, irrespective of supplier name)

I’m not using Copy/Paste FROM “Input section” to “Analysis Section”, the “Analysis Section” is using a formula {=IF(SUMPRODUCT,ROWS,INDEX,SMALL………)}
to pull the figures from the “Input Section” and list them under the Individual Suppliers, ie Rent,EDF,Micks Garage etc,

The “Analysis Section” has fixed headers.

What currently happens is, IF ANY entry in Col E matches the cell value in eg G20 (Rent), it pulls the next value from Col F and THAT value is placed it in the next blank cell under “Rent” (G20), BUT WITHOUT the “Comment.”

What I’m trying do is FROM the “Input Section” pull the “Value” and the “Comment” from ie, F??(Rent) into the next blank row under ie Rent (G20)

Everything I have posted works fine just to pull values from “Input Section” into “Analysis Section”, but I want to pull “Comments” at the time as well,
if formula option is off the table then maybe use VBA to get the “Comments” from “ Input Section” Col F to relevant cells in G26:N27 retrospect fully using separate VBA code

I do pray this has made things clearer as opposed to add more confusion, but I have my doubts!!!
 
Upvote 0
Can I stress again XI2BB didn’t show any comments that are in F5:K15 or G26:N27 so used “Fill colour” – luminous green to indicate the cells with “Comments”.
IGNORE the fact there are “Comments” in G6:K15 as they are only replicates of ones in F6:F15

The “Red/Orange” triangles in Analysis section (G21:N22) are {Array formulas} that look for entries in E5:E15 that match the names in G20:N20. If there is a match it then pulls the corresponding value from F5:F15 and puts/adds that value to the list under the “Matched Name” in the “Analysis Section”

The number of rows in “Input Section” continually increases, because the “Userform” enters its data into the first BLANK row of the “Input Section” (ie Row16) and THEN ALSO ADDS a new-blank-formatted row, so effectively bumping everything in E17:N27 down by one row.
(“Input Section” could end up having/being 500-700 rows, “Analysis Section” will then effectively be bumped down by same amount)

Transpose isn’t an option because names in F5:F??? “Input Section” will be in random order while the “Analysis Section” has fixed headings (G20:N20)
 
Upvote 0
Hi Micron,
I have failed miserably to adapt the code on the link you posted regarding copying “Comments/Notes”!!
But also been researching alternative methods to achieve what I was planning.

Is there any chance you could have a look at that code and adapt it for me to fit with a slightly different criteria to my original post??

My Minimum thinking right now is to simply copy ALL the Comments/Notes from Col F into Col Q.
Next best thing is to; retrieve values from Col E into Col P and also/then retrieve from Col F the ”Comments & values” into Col Q.

That way I may be able to filter/vLookup those Columns for specific values?

Appreciate any guidence you can give!!
Julhs
 
Upvote 0
I'll see what I can do with the 2nd option, which seems like it would be your preferred result. Not sure because it seems more robust, but to me, "next best thing" implies that which is secondary, inferior, less desirable, etc.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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