join column & variable to replace cell number "V65536"

d_carr

New Member
Joined
May 12, 2010
Messages
15
my question:

how do i join "V" (my column) and "erow_three" (my number of rows) to replace "V65536" in the following statement:

Range("X1") = "=COUNTA(V2:V65536)"


my current code:
Dim ws_three As Worksheet
Set ws_three = Sheets("Responsiveness - operations")
Sheets("Responsiveness - operations").Select
erow_three = ws_three.Cells(2, 1).End(xlDown).Row

Range("X1") = "=COUNTA(V2:V65536)"
 

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".
Hi d_carr,

For your original code, you can use this...

Code:
Dim ws_three As Worksheet
    Set ws_three = Sheets("Responsiveness - operations")
    erow_three = ws_three.Cells(2, "A").End(xlDown).Row
    
    Range("X1").Formula = "=COUNTA(V2:V" & erow_three & ")"

...or more simply just use this:

Code:
Range("X1").Formula = _
        "=COUNTA(V2:V" & Sheets("Responsiveness - operations").Range("A" & Rows.Count).End(xlUp).Row & ")"

HTH

Robert
 
Upvote 0
thanks! :)

second question:
regarding the below line of code, instead of going down to row 65500, how would i go down to the last row with data in it, regarding statement:

Range("Z2") = "=SUMPRODUCT(--(ISNUMBER(FIND(""TRUE"",U2:U65500))),--(V2:V65500=""R""))"
 
Upvote 0
Is there a column that can be relied upon to work out where the last row lies or will it have to be searched for across all columns?
 
Upvote 0
i suppose cell "AG1" could store "where the last row lies" --- if thats what u mean?

im looking for a solution to speed up my macro, thus i dont wanna go down to row 65500 if i dont have too.
 
Upvote 0
if thats what u mean

No it's not unfortunately. What I meant was is there a column I can consistently check for to determine where the last row of your data resides (just like you check Column A when you set the erow_three variable) or will I have to search for that row across all columns in the active sheet?
 
Upvote 0
OK then, see how this goes:

Code:
Dim lngLastRow As Long

    'Set the 'lngLastRow' variable based on the last row found in Column of the _
    active (current) sheet.
    lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
    
    Range("Z2").Formula = _
        "=SUMPRODUCT(--(ISNUMBER(FIND(""TRUE"",U2:U" & lngLastRow & "))),--(V2:V" & lngLastRow & "=""R""))"

Regards,

Robert
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,530
Members
448,969
Latest member
mirek8991

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