How to increment a column value if it repeats otherwise reset to 1

0 votes

I have two columns: one for image URLs and one for "Image Position." I would like the Position column to increase by 1 if the picture URL has the same "Base ID" because of this. I want to reset everything back to 1 if the Base value changes.

As an illustration, all files end with foobar-8.jpg. I require a method to determine whether Foobar modifies and, if so, whether it restarts at 1. Otherwise, keep adding a +1 as seen below. Is VBA able to handle this? I'm unable to determine using standard Excel (2013).

enter image description here

Feb 4, 2023 in Others by Kithuzzz
• 38,000 points
815 views

1 answer to this question.

0 votes

Use COUNTIF:

=COUNTIF(A$2:A2,A2) 

The absolute and relative cell coordinates are what you should focus on in the formula I proposed. The formula becomes: =COUNTIF(A$2:A7,A7), which means it counts all occurrences of the value in A7 in all the preceding rows, as A$2 remains constant as you populate it down and A2 increments up.

answered Feb 4, 2023 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

How do I get it to select a single row based on the value?

Try this: Sub MoveBasedOnValue2() Dim ...READ MORE

answered Jan 20, 2023 in Others by narikkadan
• 63,600 points
591 views
0 votes
1 answer

VBA Help to find a column based on header value and cupy it to an other worksheet

You can break out the "copy column ...READ MORE

answered Jan 26, 2023 in Others by narikkadan
• 63,600 points
2,371 views
0 votes
1 answer

How to set a column as a range variable as long as there is data in it?

Try this: Dim rng As Range Set rng = ...READ MORE

answered Feb 16, 2023 in Others by narikkadan
• 63,600 points
614 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,212 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,665 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
908 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
1,053 views
0 votes
1 answer

How to find a value in an excel column by vba code Cells.Find

Just use: Dim Cell As Range Columns("B:B").Select Set cell = ...READ MORE

answered Nov 17, 2022 in Others by narikkadan
• 63,600 points
3,769 views
0 votes
1 answer

How to unmerge multiple cells and transpose each value into a new column in Pandas dataframe from excel file

Try this: df = pd.read_excel("Sample_File.xlsx", header=[0,1,2,3,4,5], index_col = ...READ MORE

answered Jan 8, 2023 in Others by narikkadan
• 63,600 points
2,528 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP