Create a loop and stop executing when it encounters the first blank cell

We have a workbook where data from completed invoices is copied into column C of Sheet1 every month.
Column A is for the Year and Column B is for the financial period (we run 13 periods per year)

Currently this formula is on column B of sheet 1, it checks to see if column C has anything in it and if so displays the current period from a cell in Sheet2
=IF(C93<>””,Sheet2!$L$3,””)

As you can imagine this isn’t elegant and requires the cells to have the period information copied and re-pasted as values before the period changes over to the next one.

For this latest version on sheet2 we have a table with the 13 periods in column Q and column P indicates if that period is closed
I found the below code online and adapted it for my needs, it finds the first empty cell in Column B of Sheet1 and then checks Sheet2 and pastes the value of the cell in Column Q that has an empty cell beside it in Column P.

Sub GetPeriod()
Dim LastRow As Long, srcWS As Worksheet, desWS As Worksheet, x As Long
x = Range(“A2:A” & Rows.Count).Cells.SpecialCells(xlCellTypeBlanks).Row
Set srcWS = Sheets(“Sheet2”)
Set desWS = Sheets(“Sheet1”)
x = srcWS.Range(“P2:P” & srcWS.Rows.Count).Cells.SpecialCells(xlCellTypeBlanks).Row
With desWS
.Cells(.Rows.Count, “B”).End(xlUp).Offset(1) = srcWS.Range(“Q” & x)
End With
End Sub

It works well enough for a beginners attempts, however I lack the knowledge or understanding of VBA to make it loop and then stop when it reaches the last of the pasted data in column C of Sheet1

And this is where I’m hoping the forum could come to my rescue and help me out with the loop and stop commands as Ive hit a wall and cant seem to get my head around it

For this latest version on sheet2 we have a table with the 13 periods in column Q and column P indicates if that period is closed
I found the below code online and adapted it for my needs, it finds the first empty cell in Column B of Sheet1 and then checks Sheet2 and pastes the value of the cell in Column Q that has an empty cell beside it in Column P.

Sub GetPeriod()
Dim LastRow As Long, srcWS As Worksheet, desWS As Worksheet, x As Long
x = Range(“A2:A” & Rows.Count).Cells.SpecialCells(xlCellTypeBlanks).Row
Set srcWS = Sheets(“Sheet2”)
Set desWS = Sheets(“Sheet1”)
x = srcWS.Range(“P2:P” & srcWS.Rows.Count).Cells.SpecialCells(xlCellTypeBlanks).Row
With desWS
.Cells(.Rows.Count, “B”).End(xlUp).Offset(1) = srcWS.Range(“Q” & x)
End With
End Sub

It works well enough for a beginners attempts, however I lack the knowledge or understanding of VBA to make it loop and then stop when it reaches the last of the pasted data in column C of Sheet1

And this is where I’m hoping the forum could come to my rescue and help me out with the loop and stop commands as Ive hit a wall and cant seem to get my head around it.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật