corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » Excel modification


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author Excel modification
Dan
Premium Member

Avatar

Registered: 22nd Apr 02
Location: Gorleston on Sea, Norfolk
User status: Offline
17th Dec 14 at 12:52   View Garage View User's Profile U2U Member Reply With Quote

Guys, I stole some code from a template, which basically extracts rows of date from sheet 1, and inputs it into various sheets depending on which box has an x in it.

I need it to only start scanning the sheet from A5100, how do I change my code to suit this??

quote:
Private Sub Workbook_Open()

Dim i, LastRow
LastRow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Quoted Work").Range("A2:R500").ClearContents
For i = 2 To LastRow
If Sheets("Sheet1").Cells(i, "P").Value = "x" Then
Sheets("Sheet1").Cells(i, "E").EntireRow.Copy Destination:=Sheets("Quoted Work").Range("A" & Rows.Count).End(xlUp).Offset(1)
End If
Next i
LastRow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Completed Work").Range("A2:R500").ClearContents
For i = 2 To LastRow
If Sheets("Sheet1").Cells(i, "N").Value = "x" Then
Sheets("Sheet1").Cells(i, "E").EntireRow.Copy Destination:=Sheets("Completed Work").Range("A" & Rows.Count).End(xlUp).Offset(1)
End If
Next i
LastRow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Work In Progress").Range("A2:R50000").ClearContents
For i = 2 To LastRow
If Sheets("Sheet1").Cells(i, "N").Value = "x" Then
Sheets("Sheet1").Cells(i, "A").EntireRow.Copy Destination:=Sheets("Work In Progress").Range("A" & Rows.Count).End(xlUp).Offset(1)
End If
Next i
End Sub



Thanks!!


Adult GiftsClick here to vist us
evilrob
Premium Member

Avatar

Registered: 16th Mar 12
Location: Your mum's house
User status: Offline
17th Dec 14 at 12:57   View Garage View User's Profile U2U Member Reply With Quote

Change all instances of:

For i = 2 to LastRow

To:

For i = 5100 to LastRow
Dom
Member

Registered: 13th Sep 03
User status: Offline
17th Dec 14 at 18:26   View User's Profile U2U Member Reply With Quote

As Rob mentions, just change the starting point of the For Loop.

Although, is there any reason why you need to iterate through all the rows three times? Can you not bung everything in a single loop and use IF/ElseIf statements? As this would be a little quicker if you're chugging through loads of data.
Dan
Premium Member

Avatar

Registered: 22nd Apr 02
Location: Gorleston on Sea, Norfolk
User status: Offline
17th Dec 14 at 18:42   View Garage View User's Profile U2U Member Reply With Quote

I don't know what im doing lol... I just copied 1 line from somebody, and carried it on...

How can I do it more efficiently?

The only thing I like about it, I can change the rows for all to what I want to see, and run a kind of report like that.

Im sure I could probably do something once the sheets are made after opening, with regards to choosing certain dates etc?


Adult GiftsClick here to vist us

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
Help needed again ...Trotty can you help Red_Corsa Geek Day 17 1672
21st Mar 03 at 00:15
by Red_Corsa
 
is there a program that...... chris_uk Geek Day 6 1891
16th Jun 05 at 00:47
by Dan B
 
Excel Help AndyKent Geek Day 3 1451
6th Oct 07 at 10:22
by aPk
 
need an excel like programme (for free) Shane Geek Day 12 1768
13th May 08 at 14:55
by pow
 
Microsoft Excel strick206 Geek Day 10 1478
6th Jul 11 at 14:46
by Sam
 

Corsa Sport » Message Board » Off Day » Geek Day » Excel modification 30 database queries in 0.0115449 seconds