PC Review


Reply
Thread Tools Rate Thread

Basic VB questions

 
 
Pierre Fichaud
Guest
Posts: n/a
 
      29th Feb 2008
Hi,
I execute a macro in a blank sheet. The macro will extract information
from another sheet called aaa.

1) How do I get the number of non-blank rows in sheet aaa into the
variable called mr? Column 1 in sheet aaa can be used .

2) How do I place a value into the current sheet from sheet aaa? I have
coded the following:

cells(1,1).value = cells(aaa!8,5).value

TIA. Pierre.

--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
 
 
 
Earl Kiosterud
Guest
Posts: n/a
 
      29th Feb 2008
Pierre,

mr = Application.WorksheetFunction.CountA(Range(Cells(2, 1), Cells(10, 1)))

Cells(1,1).Value = sheets("aaa").Cells(8, 5).Value

--
Regards from Virginia Beach,

Earl Kiosterud
www.smokeylake.com
-----------------------------------------------------------------------
"Pierre Fichaud" <(E-Mail Removed)> wrote in message
news:47c873c9$0$26063$(E-Mail Removed)...
> Hi,
> I execute a macro in a blank sheet. The macro will extract information from another sheet
> called aaa.
>
> 1) How do I get the number of non-blank rows in sheet aaa into the variable called mr?
> Column 1 in sheet aaa can be used .
>
> 2) How do I place a value into the current sheet from sheet aaa? I have coded the
> following:
>
> cells(1,1).value = cells(aaa!8,5).value
>
> TIA. Pierre.
>
> --
> Posted via a free Usenet account from http://www.teranews.com
>



 
Reply With Quote
 
Earl Kiosterud
Guest
Posts: n/a
 
      29th Feb 2008
Pierre,

Oops. I didn't notice the sheet aaa requirement. Make that:

mr = Application.WorksheetFunction.CountA(Range(Sheets("aaa").Cells(2, 1),
Sheets("aaa").Cells(10, 1)))

Or

mr = Application.WorksheetFunction.CountA(Sheets("aaa").Range("A2:A10"))

--
Regards from Virginia Beach,

Earl Kiosterud
www.smokeylake.com
-----------------------------------------------------------------------
"Earl Kiosterud" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Pierre,
>
> mr = Application.WorksheetFunction.CountA(Range(Cells(2, 1), Cells(10, 1)))
>
> Cells(1,1).Value = sheets("aaa").Cells(8, 5).Value
>
> --
> Regards from Virginia Beach,
>
> Earl Kiosterud
> www.smokeylake.com
> -----------------------------------------------------------------------
> "Pierre Fichaud" <(E-Mail Removed)> wrote in message
> news:47c873c9$0$26063$(E-Mail Removed)...
>> Hi,
>> I execute a macro in a blank sheet. The macro will extract information from another sheet
>> called aaa.
>>
>> 1) How do I get the number of non-blank rows in sheet aaa into the variable called mr?
>> Column 1 in sheet aaa can be used .
>>
>> 2) How do I place a value into the current sheet from sheet aaa? I have coded the
>> following:
>>
>> cells(1,1).value = cells(aaa!8,5).value
>>
>> TIA. Pierre.
>>
>> --
>> Posted via a free Usenet account from http://www.teranews.com
>>

>
>



 
Reply With Quote
 
Gary''s Student
Guest
Posts: n/a
 
      29th Feb 2008
Here is coding for the first question:

Sub marine()
Sheets("aaa").Activate
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
Non_Blank_Rows = 0
For i = 1 To nLastRow
If Application.CountA(Rows(i)) > 0 Then
Non_Blank_Rows = Non_Blank_Rows + 1
End If
Next
MsgBox (Non_Blank_Rows)
mr = Non_Blank_Rows
End Sub

We cannot simply look at the limits of UsedRange. There may be blank rows
embedded in aaa.

Here is coding for the second question:

Sub servient()
Cells(1, 1).Value = Sheets("aaa").Cells(8, 5).Value
End Sub
--
Gary''s Student - gsnu2007d


"Pierre Fichaud" wrote:

> Hi,
> I execute a macro in a blank sheet. The macro will extract information
> from another sheet called aaa.
>
> 1) How do I get the number of non-blank rows in sheet aaa into the
> variable called mr? Column 1 in sheet aaa can be used .
>
> 2) How do I place a value into the current sheet from sheet aaa? I have
> coded the following:
>
> cells(1,1).value = cells(aaa!8,5).value
>
> TIA. Pierre.
>
> --
> Posted via a free Usenet account from http://www.teranews.com
>
>

 
Reply With Quote
 
Pierre Fichaud
Guest
Posts: n/a
 
      29th Feb 2008
Thanks. PF.

Earl Kiosterud wrote:
> Pierre,
>
> mr = Application.WorksheetFunction.CountA(Range(Cells(2, 1), Cells(10, 1)))
>
> Cells(1,1).Value = sheets("aaa").Cells(8, 5).Value
>


--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      1st Mar 2008
I bet you'd need to qualify the Range(), too.

And that's way too much typing:

with worksheets("aaa")
mr = Application.WorksheetFunction.CountA(.Range(.Cells(2, 1), .Cells(10, 1)))
End with

or just:
mr = Application.WorksheetFunction.CountA(Sheets("aaa").range("a2:A10"))

Earl Kiosterud wrote:
>
> Pierre,
>
> Oops. I didn't notice the sheet aaa requirement. Make that:
>
> mr = Application.WorksheetFunction.CountA(Range(Sheets("aaa").Cells(2, 1),
> Sheets("aaa").Cells(10, 1)))
>
> Or
>
> mr = Application.WorksheetFunction.CountA(Sheets("aaa").Range("A2:A10"))
>
> --
> Regards from Virginia Beach,
>
> Earl Kiosterud
> www.smokeylake.com
> -----------------------------------------------------------------------
> "Earl Kiosterud" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Pierre,
> >
> > mr = Application.WorksheetFunction.CountA(Range(Cells(2, 1), Cells(10, 1)))
> >
> > Cells(1,1).Value = sheets("aaa").Cells(8, 5).Value
> >
> > --
> > Regards from Virginia Beach,
> >
> > Earl Kiosterud
> > www.smokeylake.com
> > -----------------------------------------------------------------------
> > "Pierre Fichaud" <(E-Mail Removed)> wrote in message
> > news:47c873c9$0$26063$(E-Mail Removed)...
> >> Hi,
> >> I execute a macro in a blank sheet. The macro will extract information from another sheet
> >> called aaa.
> >>
> >> 1) How do I get the number of non-blank rows in sheet aaa into the variable called mr?
> >> Column 1 in sheet aaa can be used .
> >>
> >> 2) How do I place a value into the current sheet from sheet aaa? I have coded the
> >> following:
> >>
> >> cells(1,1).value = cells(aaa!8,5).value
> >>
> >> TIA. Pierre.
> >>
> >> --
> >> Posted via a free Usenet account from http://www.teranews.com
> >>

> >
> >


--

Dave Peterson
 
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
Basic Questions don Microsoft Access 4 12th Oct 2009 07:04 AM
Very Basic Questions about Visual Basic =?Utf-8?B?anVzdHBoaWxpcDIwMDM=?= Microsoft Access 3 17th Apr 2007 02:56 AM
Basic RAM Questions Annon Windows XP Hardware 5 12th Jul 2005 12:09 AM
Re: 2 basic questions John Barnett MVP Windows XP Basics 0 14th Sep 2004 06:55 PM
Basic RD Questions frank Windows XP Work Remotely 3 28th Jul 2004 09:50 AM


Features
 

Advertising
 

Newsgroups
 


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