Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Assigning a row to a variable

Hi all,

Have one that's driving me nuts:

I need to look at a column and find the last populated
cell of that column. Then I need to determine the first
blank row below that cell. My trouble is the next part...I
don't want to select this row or anything, I want to
assign a variable to it for use in another sub.

Hope I explained this clearly

Todd


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Assigning a row to a variable

dim myvariable as row

set myvariable = row("1:1")
myvariable.select





"Todd" wrote in message
...
Hi all,

Have one that's driving me nuts:

I need to look at a column and find the last populated
cell of that column. Then I need to determine the first
blank row below that cell. My trouble is the next part...I
don't want to select this row or anything, I want to
assign a variable to it for use in another sub.

Hope I explained this clearly

Todd




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Assigning a row to a variable

Hi
try the following
Hi
try the following macro:
Sub find_last_row()
Dim lastcell As range
dim nextcell as range

set lastcell = ActiveSheet.Cells(Rows.Count, "Z").End(xlUp)
set nextcell = lastcell.offset(1,0)
nextcell.value="New cell"
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany


Todd wrote:
Hi all,

Have one that's driving me nuts:

I need to look at a column and find the last populated
cell of that column. Then I need to determine the first
blank row below that cell. My trouble is the next part...I
don't want to select this row or anything, I want to
assign a variable to it for use in another sub.

Hope I explained this clearly

Todd

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Assigning a row to a variable

Frank Kabel wrote:

Hi
try the following
Hi
try the following macro:
Sub find_last_row()
Dim lastcell As range
dim nextcell as range

set lastcell = ActiveSheet.Cells(Rows.Count, "Z").End(xlUp)
set nextcell = lastcell.offset(1,0)
nextcell.value="New cell"
End Sub


The above code assigns to the variable "nextcell" the next cell after
the last occupied cell in Column Z whether or not the row of that cell
is blank. To do what the OP seems to be requesting, i.e., to assign to a
variable the next blank *row* (not the next blank cell), you might try:

Sub a()
Dim rng As Range, iCell As Range, myVar As Range
Set rng = Range(Range("Z65536").End(xlUp)(2), Range("Z65536"))
For Each iCell In rng
If Application.CountA(iCell.EntireRow) = 0 Then
Set myVar = iCell.EntireRow
Exit For
End If
Next
End Sub

Alan Beban
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Assigning a row to a variable

Todd,

Dim LastRow as Integer
LastRow = Range("A65536").End(xlUp).Row

Will give you the row index of the last populated cell in
column A. You can then manipulate this number to your
heart's content.

Pete.

-----Original Message-----
Hi all,

Have one that's driving me nuts:

I need to look at a column and find the last populated
cell of that column. Then I need to determine the first
blank row below that cell. My trouble is the next

part...I
don't want to select this row or anything, I want to
assign a variable to it for use in another sub.

Hope I explained this clearly

Todd


.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning values to a variable set John A[_2_] Excel Discussion (Misc queries) 1 April 23rd 10 08:20 PM
Assigning a variable Zack Excel Worksheet Functions 3 December 11th 08 07:00 PM
Assigning Variable Range JMay Excel Discussion (Misc queries) 1 July 7th 07 04:52 PM
assigning worksheet variable Simon Shaw[_4_] Excel Programming 4 May 29th 04 04:04 AM
Re-assigning the value of a variable for a for loop from Mike Berry Excel Programming 1 July 16th 03 02:41 PM


All times are GMT +1. The time now is 06:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"