Consulting

Results 1 to 7 of 7

Thread: Coding alternating blank lines w emails

  1. #1

    Coding alternating blank lines w emails

    I have a list of 4200 emails in column A in the format of xxxx@yyyy.com. I need to code something like this:

    edit 1
    set email-pattern "spam@spammer.com"
    next
    edit 2
    set email-pattern "badguy@spam.com"
    next


    Any help or places to look for info would be great! Thanks!

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Welcome to the forum. You want a blank line between each email addy?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    404
    Location
    I do not understand your problem. Try again.

    Artik

  4. #4
    Thank you! Sorry, i misworded. I dont need to insert a blank line, i meant i needed to insert the text above. For instance, Column A has list of emails. I need to insert the text around the emails. Example below:

    Looks like this now:

    Column A
    Spam@spammer.com
    Badguy@spam.com
    xxxxxx@yyyyy.com

    Trying to get it to look like this:

    Column A
    edit 1
    set email-pattern "spam@spammer.com"
    next
    edit 2
    set email-pattern "badguy@spam.com"
    next
    edit 3
    set email-pattern xxxxx@yyyy.com
    next

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Public Sub ProcessData()
    Const TEST_COLUMN As String = "A"    '<=== change to suit
    Dim i As Long
    Dim LastRow As Long
    With ActiveSheet
    LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
            For i = LastRow To 0 Step -1
    If i < LastRow Then
    .Rows(i + 1).Insert
                    With .Cells(i + 1, TEST_COLUMN)
    .Value = "edit" & i + 1
                        .Font.Underline = xlUnderlineStyleNone
                        .Font.ColorIndex = 0
                    End With
                End If
    If i > 0 Then
    .Rows(i + 1).Insert
                    With .Cells(i + 1, TEST_COLUMN)
    .Value = "next"
                        .Font.Underline = xlUnderlineStyleNone
                        .Font.ColorIndex = 0
                    End With
    .Cells(i, TEST_COLUMN).Value = "set email-pattern " & .Cells(i, TEST_COLUMN).Value
                End If
    Next i
        End With
    End Sub
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Wow that was quick! what do i need to add to put the emails in paranthesis?

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I had written it after you first post, you beat me to the draw

    Public Sub ProcessData()
    Const TEST_COLUMN As String = "A" '<=== change to suit
    Dim i As Long
    Dim LastRow As Long
    With ActiveSheet
        LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
        For i = LastRow To 0 Step -1
            If i < LastRow Then
                .Rows(i + 1).Insert
                With .Cells(i + 1, TEST_COLUMN)
                    .Value = "edit" & i + 1
                    .Font.Underline = xlUnderlineStyleNone
                    .Font.ColorIndex = 0
                End With
            End If
            If i > 0 Then
                .Rows(i + 1).Insert
                With .Cells(i + 1, TEST_COLUMN)
                    .Value = "next"
                    .Font.Underline = xlUnderlineStyleNone
                    .Font.ColorIndex = 0
                End With
                .Cells(i, TEST_COLUMN).Value = "set email-pattern """ & .Cells(i, TEST_COLUMN).Value & """"
            End If
        Next i
    End With
    End Sub
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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