Thanks for your help Ashish - I'll give it a shot! Regards, Al On Mar 4, 7:10 pm, Ashish Jain <26may.1...@gmail.com> wrote: > ---------------------------------------------------------------------------------------------------------------------------- > > Hi AI > > Your code is working fine on my system. Please re-check by closing and > opening the file. > However it doesn't matter much by try this > 1. Make S capital - i.e.take care of cases while programming - > Worksheets("*S*heet1").UsedRange.Rows.Count > 2. Check the values again in Cells(3,4) and Cells(totalRows,4) > 3. Save, Close and Re-Open the Workbook to test your code. > > FYI:- I used both MS Excel 2007 and 2003 to test your code and as a result > it returned values of Column D from 3rd Row to Last Row. > > For more tips, tricks, downloads and problem solutions: visit > -->http://www.excelitems.com > ------------------------------------------------------------------------ > Regards > *Ashish **Jain* > Analyst and Demand-Co-ordinator, CSC Australia > Microsoft Certified Application (Excel) Specialist > Technical Trainer - Excel and VBA > Author ->www.excelitems.com > 09999-40-48-43 > ---------------------------------------------------------------------------------------------------------------------------- > ---------------------------------------------------------------------------------------------------------------------------- > > > > > > On Wed, Mar 4, 2009 at 11:28 PM, tiggyboo <tiggy...@gmail.com> wrote: > > > Given this code: > > > totalRows = Worksheets("sheet1").UsedRange.Rows.Count > > For Each r In Worksheets("Sheet1").Range(Cells(3, 4), Cells(totalRows, 4)) > > > VBA gives a 1004 error immediately (does not enter the loop) on the > > For Each line - this confuses me because: > > > 1. There is a "Sheet1" worksheet > > 2. The variable totalRows resolves to an accurate number > > 3. Cells(3,4) resolves to the indended cell value > > 4. The same code works on other worksheets of similar dimensions > > > Any initial thoughts? > > > Thanks in advance, > > Al > > -- > Regards > Ashish Jain > > Sent from: United States.- Hide quoted text - > > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~ ------------------------------------------------------------------------------------- Some important links for excel users: 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 2. Excel tutorials at http://www.excel-macros.blogspot.com 3. Learn VBA Macros at http://www.vbamacros.blogspot.com 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com or Ashish Jain @ 26may.1...@gmail.com ------------------------------------------------------------------------------------- -~----------~----~----~----~------~----~------~--~---