Fill in blank cells + Create 'Record Numbers'

GFP1963

New Member
Joined
Jan 12, 2018
Messages
17
Probably not the best title to get the point across but now that you are here...:

Have a spreadsheet with rows of company names and multiple contacts per company.
The company name data is only in the row of the first contact for the company.
The subsequent company name rows are blank until the next set of company contacts begins.

Need to accomplish 2 things:

  1. Fill in the blank company name cells with the correct company name (the contacts are grouped by company)
  2. Add a numeric 'record number' for each contact per company (1 - ##), repeating at 1 for the first contact/record per company.


A sample set of data is available for review here:

  1. Sheet 1 illustrates the 'starting point'.
  2. Sheet 2 illustrates where we need to end up.

(it is a Google Sheet but am working in Excel - for Mac - version 14.6.8 :/ )
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Not sure if this works on a Mac, but try
Code:
Sub fillBlanks()

   Dim Rng As Range
   
   For Each Rng In Columns(2).SpecialCells(xlBlanks).Areas
      With Rng.Offset(-1, -1).Resize(1)
         .Value = 1
         .AutoFill Rng.Offset(-1, -1).Resize(Rng.Count + 1), xlFillSeries
      End With
      Rng.Offset(-1).Resize(Rng.Count + 1).FillDown
   Next Rng
      
End Sub
 
Upvote 0
Thank you for the reply. I was hoping there would be a formula or formulas to work with as I am an idiot when it comes to VBA. If possible could you set up a sheet with that macro? I can message you my email address or any other delivery method you prefer.
 
Upvote 0
That is fabulous! Thank you so much!
I really should start learning this VBA in my 'spare time'...
 
Upvote 0
Glad to help & thanks for the feedback.
VBA is a very helpful tool, but being on a Mac, I don't think you can use it to its fullest effect.
 
Upvote 0
Sorry to bother again but now I have sheets where the company name IS on every row and I just need to add the 'record numbers'. Can do..?
 
Upvote 0
Put this formula in A2 & copy down
=COUNTIF(B$2:B2,B2)
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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