Neighborhood directory

JimS63

New Member
Joined
Dec 8, 2020
Messages
21
Office Version
  1. 365
Platform
  1. Windows
Sunday School Test.xlsm
DEFGHIJKLM
1E-MailPhoneNameBirthdayE-mailPhoneAddressCityStateZip
2Glen@mail.com816-552-Cindy1-FebCindy@mail.com816-55717 ElmRaymoreMO64083
3John@mail.com816-553Susan21-NovSusan@mail.com816-55818 AshPeculiarMO64078
4Janie@mail.com816-55419 WalnutRaymoreMO64078
5Glenna@mail.com816-55520 OakRaymoreMO64083
6Jim@mail.com816-556Kathy4-NovKathy@mail.com816-55921 PecanRaymoreMO64083
Contacts


I have this worksheet and I want to create a birthday list on a second worksheet.

My output should be in the form
Jan 4 First and Last Name
Feb 7 First and Last Name

I am trying to do it with copying only non blank cells and the cells next to them onto another table on the second sheet.

Here is my code
VBA Code:
Sub CopyAndPasteNonBlanks()
Dim rng As Range

Set rng = Range("C2:C50").SpecialCells(xlCellTypeConstants)
rng.Copy Range("O2")

Set rng = Range("B2:B50").SpecialCells(xlCellTypeConstants)
rng.Copy Range("P2")

Set rng = Range("A2:A50").SpecialCells(xlCellTypeConstants)
rng.Copy Range("Q2")


Set rng = Range("G2:G50").SpecialCells(xlCellTypeConstants)
rng.Copy Range("O7")

Set rng = Range("F2:F50").SpecialCells(xlCellTypeConstants)
rng.Copy Range("P7")

Set rng = Range("A2:A50").SpecialCells(xlCellTypeConstants)
rng.Copy Range("Q7")

End Sub

Here is my result
Results.jpg


I need the code to find the first blank cell for the second set of names.
I also need the last names to only paste if the first name is not blank

Can one of you fine folks help me out?

I plan on using mail merge on this list into a Word document for printing.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Sorry the mini sheet doesn't contain all the data

Sunday School Test.xlsm
ABCDEFGHIJKLM
1Family NameGiven NameBirthdayE-MailPhoneNameBirthdayE-mailPhoneAddressCityStateZip
2AdamsGlen12-SepGlen@mail.com816-552-Cindy1-FebCindy@mail.com816-55717 ElmRaymoreMO64083
3SmithJohn10-NovJohn@mail.com816-553Susan21-NovSusan@mail.com816-55818 AshPeculiarMO64078
4DavisJanie15-SepJanie@mail.com816-55419 WalnutRaymoreMO64078
5FowlerGlenna25-NovGlenna@mail.com816-55520 OakRaymoreMO64083
6WeeksJim22-FebJim@mail.com816-556Kathy4-NovKathy@mail.com816-55921 PecanRaymoreMO64083
Contacts
 
Upvote 0
How about
VBA Code:
Sub CopyAndPasteNonBlanks()
   Dim NxtRw As Long
   
   With Range("C2:C50").SpecialCells(xlCellTypeConstants)
      .Copy Range("O2")
      .Offset(, -1).Copy Range("P2")
      .Offset(, -2).Copy Range("Q2")
   End With
   
   NxtRw = Range("O" & Rows.count).End(xlUp).Offset(1).Row
   
   With Range("G2:G50").SpecialCells(xlCellTypeConstants)
      .Copy Range("O" & NxtRw)
      .Offset(, -1).Copy Range("P" & NxtRw)
      .Offset(, -6).Copy Range("Q" & NxtRw)
   End With
End Sub
 
Upvote 0
Create a sheet named "Birthdays" and place the headers in row 1. Then try this macro:
VBA Code:
Sub CreateBirthdayList()
    Application.ScreenUpdating = False
    Dim LastRow As Long, srcWS As Worksheet, desWS As Worksheet, v As Variant, i As Long
    Set srcWS = Sheets("Contacts")
    Set desWS = Sheets("Birthdays")
    LastRow = srcWS.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    v = srcWS.Range("A2", srcWS.Range("C" & Rows.Count).End(xlUp)).Value
    For i = LBound(v) To UBound(v)
        If v(i, 2) <> "" Then
            With desWS
                .Cells(.Rows.Count, "A").End(xlUp).Offset(1).Resize(, 3).Value = Array(v(i, 3), v(i, 2), v(i, 1))
            End With
        End If
    Next i
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks for the code.

That worked for Column B and C but did not give me the birthdays of spouses in Column F and G. This is where my coding falls short. I don't need the spouses together if that helps.
 
Upvote 0
How about
VBA Code:
Sub CopyAndPasteNonBlanks()
   Dim NxtRw As Long
  
   With Range("C2:C50").SpecialCells(xlCellTypeConstants)
      .Copy Range("O2")
      .Offset(, -1).Copy Range("P2")
      .Offset(, -2).Copy Range("Q2")
   End With
  
   NxtRw = Range("O" & Rows.count).End(xlUp).Offset(1).Row
  
   With Range("G2:G50").SpecialCells(xlCellTypeConstants)
      .Copy Range("O" & NxtRw)
      .Offset(, -1).Copy Range("P" & NxtRw)
      .Offset(, -6).Copy Range("Q" & NxtRw)
   End With
End Sub
This one worked perfect! Thank you so much.

Is there a way to put it onto a different worksheet?
 
Upvote 0
This should do it:
VBA Code:
Sub CreateBirthdayList()
    Application.ScreenUpdating = False
    Dim LastRow As Long, srcWS As Worksheet, desWS As Worksheet, v As Variant, i As Long
    Set srcWS = Sheets("Contacts")
    Set desWS = Sheets("Birthdays")
    LastRow = srcWS.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    v = srcWS.Range("A2", srcWS.Range("A" & Rows.Count).End(xlUp)).Resize(, 7).Value
    For i = LBound(v) To UBound(v)
        If v(i, 2) <> "" Then
            With desWS
                .Cells(.Rows.Count, "A").End(xlUp).Offset(1).Resize(, 5).Value = Array(v(i, 3), v(i, 2), v(i, 1), v(i, 6), v(i, 7))
            End With
        End If
    Next i
    Application.ScreenUpdating = True
End Sub
Make sure you have a sheet named "Birthdays".
 
Upvote 0
Is there a way to put it onto a different worksheet?
Yup, like
VBA Code:
Sub CopyAndPasteNonBlanks()
   Dim NxtRw As Long
   
   With Range("C2:C50").SpecialCells(xlCellTypeConstants)
      .Copy Sheets("Sheet1").Range("O2")
      .Offset(, -1).Copy Sheets("Sheet1").Range("P2")
      .Offset(, -2).Copy Sheets("Sheet1").Range("Q2")
   End With
   
   NxtRw = Sheets("Sheet1").Range("O" & Rows.count).End(xlUp).Offset(1).Row
   
   With Range("G2:G50").SpecialCells(xlCellTypeConstants)
      .Copy Sheets("Sheet1").Range("O" & NxtRw)
      .Offset(, -1).Copy Sheets("Sheet1").Range("P" & NxtRw)
      .Offset(, -6).Copy Sheets("Sheet1").Range("Q" & NxtRw)
   End With
End Sub
 
Upvote 0
Yup, like
VBA Code:
Sub CopyAndPasteNonBlanks()
   Dim NxtRw As Long
  
   With Range("C2:C50").SpecialCells(xlCellTypeConstants)
      .Copy Sheets("Sheet1").Range("O2")
      .Offset(, -1).Copy Sheets("Sheet1").Range("P2")
      .Offset(, -2).Copy Sheets("Sheet1").Range("Q2")
   End With
  
   NxtRw = Sheets("Sheet1").Range("O" & Rows.count).End(xlUp).Offset(1).Row
  
   With Range("G2:G50").SpecialCells(xlCellTypeConstants)
      .Copy Sheets("Sheet1").Range("O" & NxtRw)
      .Offset(, -1).Copy Sheets("Sheet1").Range("P" & NxtRw)
      .Offset(, -6).Copy Sheets("Sheet1").Range("Q" & NxtRw)
   End With
End Sub
Thank you for all your help. Works a champ!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,930
Members
449,094
Latest member
teemeren

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