simple macro help

ultratch47

Board Regular
Joined
Aug 6, 2002
Messages
126
i have a list of data in one column (maybe 900 rows long)
i would like for this macro (using XL macro recorder) to give me the row # of the last row in this list

IE.
list is C2:C956
macro will place "956" in cell C1 (this number needs to be a regularly written number as it will be used in a formula later on)

thanks for all the help in advance
Tek
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Right mouse over the sheet name (i.e. Sheet1) and select view code, then paste this in;

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Range("C1").Value = Range("C65536").End(xlUp).Row
End Sub

Make an amendment to you sheet (i.e. change a cell) and it will run...
 
Upvote 0
How about:

Sub NumRows
With Application.ActiveSheet
Range("C1") = .Range("C65535").End(xlUp).Row
End With
End Sub
 
Upvote 0
Thanks guys
i can't write code, so i hvae another question

do i need the Sub and End Sub commands if this is being used WITHIN another macro
 
Upvote 0
You only need one Sub/End Sub per macro.

if you want the number in another macro use this

Code:
Dim myrow as long
myrow = range("C65536").end(xlup).row
 
Upvote 0
ok another question

i have a formula for counting the blanks within the above list:
IE. =CountBlank(C2:C???)
how do i tell excel what the last reference is (inside the formula while inside a macro)

i am so confused
:cry:
 
Upvote 0
This should do it;

Code:
Dim myrow As Long
myrow = Range("C65536").End(xlUp).Row
Range("E1").FormulaR1C1 = "=COUNTBLANK(R2C3:R" & myrow & "C3)"
 
Upvote 0
ok
this macro will require the need seperate two sets of data
IE. C2:C900 is one set
BLANK in between
C902:C1500 is another set
i need to just simply delete the second set with a macro line (i will create another macro for the other set later)

so macro will need to identify the FIRST blank in this row (since that blank seperating the sets is the only blank in this column) and delete the entire row below that one cell...

thanks
 
Upvote 0
This will delete the first row with a blank cell in column C (from C2 downwards)

Code:
Range("C2").End(xlDown).Offset(1, 0).EntireRow.Delete
 
Upvote 0
jimboy,

the macro then needs to delete ALL rows from that blank and downward

if blank is C901

delete C901:C65536

thanks for the continued assistance

(y)
 
Upvote 0

Forum statistics

Threads
1,203,326
Messages
6,054,745
Members
444,748
Latest member
knowak87

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