Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a new worksheet from another

Hi

I have a little problem, any help would be GREAT!

Heres what Im trying to do,

I have a worksheet, column A has company names, and column B either ha
an 'S' or an 'L'.


Now in another worksheet, I want to print all the company names i
column A that have an "L" in column B, starting at row 4.

This is what I have:

rivate Sub Large_Click()
Dim i As Long
Dim j As Long
Dim company As String

Sheet2.Activate
Sheet2.Range("A4").Select

Count = 0
For j = 1 To Sheet2.Range("A65536").End(xlUp).Row
If Sheet2.Range("B" & j).Value = "L" Then
Count = Count + 1
End If
Next

For i = 1 To Count
Sheet2.Activate
For j = 1 To Sheet2.Range("A65536").End(xlUp).Row
If Sheet2.Range("B" & j).Value = "L" Then
company = Sheet2.Range("A" & j).Value
Sheet4.Activate
Sheet4.Range("A" & i + 3).Value = company
End If
Next j
Next i

Sheet4.Activate

End Sub

Problems with this:

1. it only prints the last of the three companies, three times
2. If I add an 'Exit For' for btoh loops, then it only prints the firs
such comapny, once
3. If I only add an 'Exit For' for the inner loop, it prints the firs
of the three companies, three times
4. If I only add an 'Exit For' for the outer loop, it only prints th
last of the three companies, once

Any help or ideas??

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a new worksheet from another

This is untested, but I think it will do the trick:


Code
-------------------
Sub test()

Dim i As Long
Dim iRow As Long

Sheets("Sheet2").Select
iRow = 4
For i = 4 To Range("A65536").End(xlUp).Row
If Range("B" & i).Value = "L" Then
Sheet4.Range("A" & iRow).Value = Range("A" & i).Value
iRow = iRow + 1
End If
Next

End Su
-------------------



--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating a new worksheet from another

Thank you so much!!!!!!!!

Sheen

--
Message posted from http://www.ExcelForum.com

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
Creating worksheets within a worksheet waldeck Excel Discussion (Misc queries) 1 May 5th 08 05:51 PM
Need help creating an attendance worksheet Mitch Excel Discussion (Misc queries) 1 February 5th 07 12:12 PM
Creating a Worksheet zephyr Excel Discussion (Misc queries) 2 September 11th 06 07:25 AM
Creating a master worksheet lrobin65 Excel Worksheet Functions 1 February 27th 06 03:22 PM
Creating a worksheet in Spanish Kent Excel Discussion (Misc queries) 1 March 1st 05 05:16 PM


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