Paste upon command


Posted by Alex Shahidi on January 20, 2002 9:11 AM

I am trying to have the following occur when a command button is clicked:

determine how many names there are and paste Jan under month label for the first half of names, and paste Feb for the second half. I need it to paste (or something similar) and not be a formula.

Name Month
A
B
C
.
.
.
N

Thank you.

Alex



Posted by Polonius on January 20, 2002 4:25 PM


Assuming your data starts in A1 :-

Sub Fill_Month()
Dim rng As Range, c%, f As Range, s As Range, r%
Set rng = Range([A1], [A65536].End(xlUp))
c = rng.Cells.Count
r = Application.WorksheetFunction.RoundUp(c / 2, 0)
Set f = Range(rng(1, 2), rng(r, 2))
Set s = Range(rng(r + 1, 2), rng(c, 2))
f.Value = "Jan"
s.Value = "Feb"
End Sub