+ Reply to Thread
Results 1 to 3 of 3

How do you make the Range vary depending on the data?

  1. #1
    Registered User
    Join Date
    10-18-2011
    Location
    Where do we go now?
    MS-Off Ver
    Excel 2010
    Posts
    22

    How do you make the Range vary depending on the data?

    Basically, I want the VBA to skip three rows and read the next line if the text in the current row is in bold font and skip 2 rows and read the next line if the text in the current row is not bold.

    My code thus far:

    Sub Bold()

    Dim i As Range

    For Each i In Range("A1:A6")

    If FontBold = True Then

    Range("A" & i).Select - This declaration of the range doesn't work! How can I fix it?
    Selection.Copy
    Range("F" & i).Select
    ActiveSheet.Paste

    i = i + 3

    Else

    Range("A" & i).Select
    Selection.Copy
    Range("F" & i).Select
    ActiveSheet.Paste

    i = i + 2

    End If

    Next

    End Sub
    Thanks!!
    Attached Files Attached Files
    Last edited by Durlov; 05-11-2012 at 12:24 PM.

  2. #2
    Registered User
    Join Date
    10-18-2011
    Location
    Where do we go now?
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: How do you make the Range vary depending on the data?

    Okay, I just realized I have more to do than the above code would establish. But Basically the data is in column A and the re-arranged data (done manually) is in column F to H. I'm guessing to re-arrange the data I would need two more variables j and k. One to keep going horizontally and one to keep going vertically. NOTE that the data repeats itself depending on the date which is in bold.

    Thanks!
    Last edited by Durlov; 05-11-2012 at 12:30 PM.

  3. #3
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: How do you make the Range vary depending on the data?

    Can you upload a workbook (or a mockup of a workbook)?

    And before the Moderators notice, you might want to wrap your code in code tags (read the forum rules).

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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