PC Review


Reply
Thread Tools Rate Thread

To change Columns(4).Rows.Count

 
 
=?Utf-8?B?T3JsYW5kbw==?=
Guest
Posts: n/a
 
      23rd Aug 2007
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 With Quote
 
 
 
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      23rd Aug 2007
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I count Rows and Columns Jean Osorio Microsoft Excel Programming 3 16th Jun 2009 03:18 PM
Count if in multiple rows / columns chanse44 Microsoft Excel Misc 1 18th Nov 2008 01:00 AM
Excel 2003 - change columns to rows and rows to columns =?Utf-8?B?VHJpc2g=?= Microsoft Excel Misc 0 17th Aug 2007 02:22 AM
RE: Excel 2003 - change columns to rows and rows to columns =?Utf-8?B?SkxhdGhhbQ==?= Microsoft Excel Misc 0 17th Aug 2007 02:05 AM
Count unique rows and columns George Microsoft Excel Worksheet Functions 2 5th Aug 2004 06:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:44 PM.