Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9257663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:11:47+00:00 2026-06-18T12:11:47+00:00

I work currently to create a VBA macro which will search for the column

  • 0

I work currently to create a VBA macro which will search for the column called “Email” or “Email – personal email” (this is the same column but these 2 names are substitutes).

So first search for the Email column, while found then check if there are any dots at the end of the email addresses. If yes it should delete them.

I have limited VBA knowledge and I am not the IT preson. So I mostly use and amend existing scripts which I found on the internet. Below is the code which I made combining 2 macros. It works fine but only when the email column is in the same place (in this case column S). How should I amend the code to use the column where Email header had been spotted?

My code:

Sub GOOD_WORKS_No_Dots_at_End_of_Emails()
    Dim strSearch As String
    Dim aCell As Range

    strSearch = "Email*"

    Set aCell = Sheet2.Rows(1).Find(What:=strSearch, LookIn:=xlValues, _
    LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False)

    If Not aCell Is Nothing Then
        Sheets("Data").Activate
            Dim LR As Long, i As Long
            LR = Range("S" & Rows.Count).End(xlUp).Row
            For i = 1 To LR
                With Range("S" & i)
                    If Right(.Value, 1) = "." Then .Value = Left(.Value, Len(.Value) - 1)
                End With
            Next i
            Sheets("Automation").Activate
            MsgBox "No Dots at the end of email addresses - Done!"
            End If
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:11:48+00:00Added an answer on June 18, 2026 at 12:11 pm

    the following should work

    'rowNum<~~~ Enter the row number your "Header fields" are in
     'returns a dictionary object
    Function getAllColNum(ByVal rowNum As Long, ByVal searchString As Variant) As Object
        Dim allColNum As Object
        Dim i As Long
        Dim j As Long
        Dim width As Long
        Set allColNum = CreateObject("Scripting.Dictionary")
        colNum = 1
        With ActiveSheet
            width = .Cells(rowNum, .Columns.Count).End(xlToLeft).Column
            For i = 1 To width
                 If InStr(UCase(Trim(.Cells(rowNum, i).Value)), UCase(Trim(searchString))) > 0 Then
                     allColNum.Add i, ""
                 End If '
            Next i
        End With
        Set getAllColNum = allColNum
    End Function
    
    
    
    Sub GOOD_WORKS_No_Dots_at_End_of_Emails()
        Dim strSearch As String
        strSearch = "Email"
        Dim colNum As Variant
        Dim allColNum As Object
        Sheets("Data").Activate
        Dim LR As Long, i As Long
        Set allColNum = getAllColNum(1, searchString)
        For Each colNum In allColNum
            LR = Cells(Rows.Count, colNum).End(xlUp).Row
            For i = 1 To LR
                With Range(Cells(i, colNum), Cells(i, colNum))
                    If Right(.Value, 1) = "." Then .Value = Left(.Value, Len(.Value) - 1)
                End With
            Next i
        Next colNum
        Sheets("Automation").Activate
        MsgBox "No Dots at the end of email addresses - Done!"
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently create a class which inherits from a Popup . Finally it will
We are currently looking to create a text-editor in WPF (.NET 4.0) which will
I'm currently working on a small webapp where I work. I've created this for
My place of work currently uses CVS. A git migration is planned but it
I currently work on a magento webshop, which loads PrototypeJS as framework. However i
I'm new to VBA but I'm trying to get a DYMO LabelWriter to work
I am currently trying to create a system in which I want to be
I've inherited a bunch of Fluent NHibernate mappings, which all currently work in the
I am currently trying to create a timer for an android game which has
This may be something trivial but I really can't get it to work, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.