Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default To change Columns(4).Rows.Count

Hi guys I would like to know how to sustitute the "Columns(4).Rows.Count"
statement for something more efficient, the Idea is to know in wich cell I
find the last record, instead off read all the column , there are no empty
cells in between, I had to assign Long to "i" because I got an overflow with
byte or integer.

Thanks


Dim i As Long, j As Integer

For j = 1 To 10
For i = 1 To Columns(4).Rows.Count
If Cells(i, 4) = Cells(j, 1) Then
Cells(i, 5) = Range("Especias")(j, 2).Value
End If
Next i
Next j

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default To change Columns(4).Rows.Count

You can get the last row for that column with
lr4 = Cells(rows.Count, 4).End(xlUp).Row
And then just plug it into
For i = 1 To lr4
The way you have it would equal 1 To 65356.
With the lr4 it will only go to the last row in that column with data.

"Orlando" wrote:

Hi guys I would like to know how to sustitute the "Columns(4).Rows.Count"
statement for something more efficient, the Idea is to know in wich cell I
find the last record, instead off read all the column , there are no empty
cells in between, I had to assign Long to "i" because I got an overflow with
byte or integer.

Thanks


Dim i As Long, j As Integer

For j = 1 To 10
For i = 1 To Columns(4).Rows.Count
If Cells(i, 4) = Cells(j, 1) Then
Cells(i, 5) = Range("Especias")(j, 2).Value
End If
Next i
Next j

End Sub

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
Count rows with criteria from two columns? Bert Hyman Excel Worksheet Functions 3 January 16th 09 01:17 AM
Excel 2003 - change columns to rows and rows to columns Trish Excel Discussion (Misc queries) 0 August 17th 07 02:22 AM
Excel 2003 - change columns to rows and rows to columns JLatham Excel Discussion (Misc queries) 0 August 17th 07 02:05 AM
Count entries in columns and rows Cliff Excel Worksheet Functions 3 April 6th 06 01:29 AM
Reduce columns and rows count? murat Excel Worksheet Functions 3 March 16th 05 07:43 PM


All times are GMT +1. The time now is 06:38 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"