Using of code / macros

ReflexTech1

New Member
Joined
Oct 1, 2018
Messages
6
Will someone please help me with writing of the code for a macro? I would like to run it on a newly opened document.
Basically, I want the one column to use all of the rows which contain the same numbers, to give me a total of the corresponding rows' column. E.g A1,A2,A3,A9,A15 are the same ( E.g 256 ) and have a corresponding quantity in column C. To keep the number ( 256 ) the same and total up the quantity. Then basically have the one number displaying in A1 with a total quantity in C1. I want to run this macro on different exported documents, if possible.

Please advise. I have been struggling with this issue for a long time.

Thank you in advance.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Reflex,

If I understand correctly, column A will have values, some will be '256'.
You want to sum the corresponding values in column C for each match of the cell A1 value of '256' in column A.

The SUMIF Function will accomplish that without a macro:

Assuming the value '256' is in cell A1 (without the single quotes), then enter this formula in cell C1:
Code:
     =SUMIF(A2:A15,A1,C2:C15)
If you want to get the sum for the value '200' on that same document, then change the value in A1 to '200'. Then all you need do when you enter the formula in cell C1 for other documents is change the last row, ie. '15' would become '26' or whatever the last row is.
Code:
     =SUMIF(A2:A26,A1,C2:C26)


Perpa
 
Upvote 0
Reflex,

If I understand correctly, column A will have values, some will be '256'.
You want to sum the corresponding values in column C for each match of the cell A1 value of '256' in column A.

The SUMIF Function will accomplish that without a macro:

Assuming the value '256' is in cell A1 (without the single quotes), then enter this formula in cell C1:
Code:
     =SUMIF(A2:A15,A1,C2:C15)
If you want to get the sum for the value '200' on that same document, then change the value in A1 to '200'. Then all you need do when you enter the formula in cell C1 for other documents is change the last row, ie. '15' would become '26' or whatever the last row is.
Code:
     =SUMIF(A2:A26,A1,C2:C26)


Perpa

I have inserted the code and adapted it to the document. Will I be able to upload an example for you to access? If your time permits. The main issue here is that it gets exported from another system, then I want to find an easier way to work through the given information. The code, provided, only gives me "0".

Thank you beforehand
 
Upvote 0
Reflex,
It would be best if you post a sample of your Excel worksheet. With that information we can then see what the format looks like and better assist you. You can use Forum Tools or one of the other posting tools available on this site.
Forum Tools:
https://www.dropbox.com/s/umis204g6eacu7m/Forum Tools.xlam?dl=0


MrExcel HTML Maker 2017:
https://onedrive.live.com/?id=8CFFDEC0CE27E813!189&cid=8CFFDEC0CE27E813


Or you can post an image using imgur.com, or a similar site, to create the posting format needed to add an image to your next post. If you use imgur.com, copy the image link and be sure to add '.jpg' on the end of the link so the image will be displayed in your post.
Perpa
 
Upvote 0
Reflex,
It would be best if you post a sample of your Excel worksheet. With that information we can then see what the format looks like and better assist you. You can use Forum Tools or one of the other posting tools available on this site.
Forum Tools:
https://www.dropbox.com/s/umis204g6eacu7m/Forum Tools.xlam?dl=0


MrExcel HTML Maker 2017:
https://onedrive.live.com/?id=8CFFDEC0CE27E813!189&cid=8CFFDEC0CE27E813


Or you can post an image using imgur.com, or a similar site, to create the posting format needed to add an image to your next post. If you use imgur.com, copy the image link and be sure to add '.jpg' on the end of the link so the image will be displayed in your post.
Perpa



The link to my upload is:

https://1drv.ms/x/s!AuJ-0PBi_0v4g27NhsX3YBUDv8DO

Details to be found in document

Thank you in advance
 
Upvote 0
Reflex,
I realize you are new to Mr Excel, but I prefer not to upload files from sites like this to avoid the possibility of uploading a virus. That is why I showed links to 'MrExcel HTML Maker 2017' and 'Forum Tools', Or Imgur.com to post a picture that everyone can see and don't need to go to that site.

If someone else would like to go to your upload site I will defer to them. Otherwise I would recommend
that you use the posting tools I provided links for.
Perpa
 
Upvote 0
Reflex1...I received the following Private Message from you, but when I tried to respond to it I got the message:
"The following errors occurred with your submission
ReflexTech1 has chosen not to receive private messages or may not be allowed to receive private messages. Therefore you may not send your message to him/her."
You may have to amend your Private Messaging settings to allow responses.


So I reverted back to the this Forum to respond to your message:
ReflexTech1 said:
Hi,
I would just like to confirm if i should upload a .jpeg file on to the onedrive account link you sent in the post "Using macro..."
Please confirm.
Thank you in advance.
Reflex1


Reflex1
To post an image using Imgur:
You need to store your image in an online free storage area like Imgur: http://imgur.com/
'Imgur: The most awesome images on the Internet'
Then post the link to the image in your posting on this Forum.
In Imgur when you move the cursor over the image you should see a side bar where it shows the links you can copy. There are about 5 or 6 selections: You need to copy the link shown as: "Message Boards and Forums"


Then when making a posting on this Forum you will see a small icon below the 'Smiley Sun' on the menu bar which says 'Insert image' when you hover over the icon. First copy the link, then click the 'Insert image' icon, and then paste the link. Make sure the link includes '.jpg' to display the picture/image. If the '.jpg' is not included then we will only see the link, not the picture.
I hope this helps.
Perpa
 
Upvote 0
j1wzG4A.jpg
[/IMG]
Please let me know if any information is needed. I would like the program to check if the content in column "B" is the same, it should add the content of the corresponding row in column "J".

Thank you for the help.
 
Upvote 0
Reflex1...I received the following Private Message from you, but when I tried to respond to it I got the message:
"The following errors occurred with your submission
ReflexTech1 has chosen not to receive private messages or may not be allowed to receive private messages. Therefore you may not send your message to him/her."
You may have to amend your Private Messaging settings to allow responses.


So I reverted back to the this Forum to respond to your message:



Reflex1
To post an image using Imgur:
You need to store your image in an online free storage area like Imgur: http://imgur.com/
'Imgur: The most awesome images on the Internet'
Then post the link to the image in your posting on this Forum.
In Imgur when you move the cursor over the image you should see a side bar where it shows the links you can copy. There are about 5 or 6 selections: You need to copy the link shown as: "Message Boards and Forums"


Then when making a posting on this Forum you will see a small icon below the 'Smiley Sun' on the menu bar which says 'Insert image' when you hover over the icon. First copy the link, then click the 'Insert image' icon, and then paste the link. Make sure the link includes '.jpg' to display the picture/image. If the '.jpg' is not included then we will only see the link, not the picture.
I hope this helps.
Perpa

j1wzG4A.jpg
[/IMG]

I did not see the previous post of the img, so I believe this is more successful.
If time allows.

I would like Excel to check the contents of the cell in column "B", if they are the same, then the "Quantity" in column "J" should be added. The basic outcome will then produce me with a breakdown of each number, instead of having 7 500 rows of information, to have the specific numbers of column "B", if different and their respective totals.

All of your help is greatly appreciated.
 
Upvote 0
Reflex1,
The method I gave you in post 2 using SUMIF will work, but requires you to enter the 'Name' value into a cell. Earlier you had indicated cell A1 is where you wanted to enter that 'Name' and the SUMIF formula would be in C1, adding the corresponding values in column C. The format you have posted in 8 appears much different than that, I think your data has changed since your initial post. You cannot merge row 1 columns A through K if you want to use cell A1 to enter the search string, and cell C1 for the corresponding sum.

You should try using a pivot table to get the summary you seek. You could put the pivot table on another 'Summary' sheet. Basically you would select ALL of your data, then go to the 'Insert' tab on the top ribbon and select 'Pivot Table'. Follow the directions to select column B data and to get the Sum of each 'Name' of the corresponding values in column J.

I think the pivot table approach will serve you better. There are numerous examples on this Forum, just search 'pivot table'.
Perpa
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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