+ Reply to Thread
Results 1 to 6 of 6

For Loop until empty cell

  1. #1
    Registered User
    Join Date
    05-23-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 2010
    Posts
    19

    For Loop until empty cell

    Hi All,

    I am trying to get the script to copy the chart and paste as picture using data from a list (offset List until empty cell).

    The VBA below ran successfully but did not do the 1st FOR LOOP that I wanted it to.


    Sub xxx()

    '
    ' Prevents Screen Refreshing
    Application.ScreenUpdating = False

    Worksheets("Sheet3").Select
    Columns("B:B").Select
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlToLeft

    Worksheets("Sheet1").Select
    Columns("A:A").Select
    Selection.Copy
    Sheets("Sheet3").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    ActiveSheet.Range("$B$1:$B$385").RemoveDuplicates Columns:=1, Header:=xlYes
    Range("B2:B37").Select
    Selection.Copy
    Sheets("Sheet2").Select
    Range("I2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    Range("B6").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = _
    "=IF(R2C2="""","""",SUMIFS(Sheet1!C[1],Sheet1!C1,R2C2,Sheet1!C2,RC1))"

    Dim x As Integer
    ' Set Numrows = number of rows of data
    numrows = Range("I2", Range("I2").End(xlDown)).Rows.Count
    ' Select cell B2
    Range("B2").Select
    ' Establish "For" loop to loop "numrows" number of times
    For x = 1 To numrows

    ActiveCell.FormulaR1C1 = "=RC[7]"

    Dim arange As Range

    Range("A5:F29").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("A38").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Set arange = Range("A38:F62")

    For Each cell In arange
    If cell.Text = "#N/A" Then
    cell.ClearContents
    End If

    Next
    Next

    End Sub

  2. #2
    Registered User
    Join Date
    05-23-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 2010
    Posts
    19

    Re: For Loop until empty cell

    Anyone Please help...

  3. #3
    Registered User
    Join Date
    05-23-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 2010
    Posts
    19

    Re: For Loop until empty cell

    Anyone...please

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,613

    Re: For Loop until empty cell

    Hi,
    First of all - follow the rules. Edit your post and use code tags. If you need additional explanation - visit http://www.excelforum.com/forum-rule...rum-rules.html

    Then merit: I think that the main issue with "not working loop" is that you refer to active cell, whle you do not change it.
    If the rest of code works fine and you want the loop go through the sells in column B then probably instead of
    Please Login or Register  to view this content.
    you shall use:
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  5. #5
    Registered User
    Join Date
    05-23-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 2010
    Posts
    19

    Re: For Loop until empty cell

    Thanks Kaper for your contribution.

    I am using the formula to read a distinct list on column I.

    And your advice work but it only copied one picture. I required a VBA to be able to copy the chart, based on the list on Column I, and paste as pictures.

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,592

    Re: For Loop until empty cell

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Loop until Cell Empty
    By Chris424 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-12-2015, 06:39 AM
  2. Loop until cell is empty
    By patocj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-07-2013, 03:22 PM
  3. [SOLVED] Loop until empty cell
    By kamran_ijazz in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-27-2012, 06:45 AM
  4. [SOLVED] Loop Until Empty Cell
    By gtiguy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-19-2012, 09:20 PM
  5. [SOLVED] Loop until cell is empty
    By Ricky Pang in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-12-2006, 12:20 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1