Free Microsoft Excel 2013 Quick Reference

Simple Excel VBA to Send & Receive Strings to/from an IP Address

What is the simpleest method to send and receive text strings to/from an IP address and port (ex.- XX.XXX.XX.XX:2000)? The objective is to to inquire and recieve readings from a laboratory device. I do not want to use forms to imbed controls as I want to make the code as portable as possible. The IP address and port are fixed and the "command" strings are three and four character strings preceeded by an asterisk. An example of pseudo code:

Connect to XX.XXX.XX.XX:2000
Send "*SRTF"

Post your answer or comment

comments powered by Disqus
Hi Guys,

I want to extract the class C address from an IP address via a formula in Excel. For example the IP address should return a class C address and the IP address should return a class C address Is this possible ?


I need to use to following VBA to send 106 emails, each with an attachment of up to 4mb.

Sub SendEmail()
Dim OutlookApp As Object
Dim MItem As Object
Dim cell As Range
Dim email_ As String
Dim subject_ As String
Dim body_ As String
Dim attach_ As String

'Create Outlook object
Set OutlookApp = CreateObject("Outlook.Application")

' Loop through the rows
For Each cell In Columns("a").Cells.SpecialCells(xlCellTypeConstants)

email_ = cell.Value
subject_ = cell.Offset(0, 1).Value
body_ = cell.Offset(0, 2).Value

'Create Mail Item and send it
Set MItem = OutlookApp.CreateItem(0)
With MItem
.To = email_
.Subject = subject_
.Body = body_
End With
End Sub In order not to exceed my mailbox limit, I think I need to delete each email after it has been sent. Can anybody advise how I can do this? Or even suggest an alternative solution?


I have an excel file with an embedded word document in it. I'm trying to create a macro to send a memo from Lotus Notes that has the embedded document in it. I don't want it as an attachment to the memo. I want it to show up as a "picture" within the memo so others can't edit it. Does anyone know how to do this?

I want to retrieve part of the string from an excel formula. For e.g.


I want the last two characters. I tried the right function, but this works on the value rather than on the formula. Any work around?

I'm using Excel VBA to send out an e-mail. I wish to change the signature (Scott Smith) font to Script MT Bold but don't know how to do it. This is the code I'm using

Dim objOL As New Outlook.Application 
Dim objMail As MailItem 
Set objOL = New Outlook.Application 
Set objMail = objOL.CreateItem(olMailItem) 
With objMail 
    .To = send_to 
    .Subject = "Status" 
    .Body = "Sir/Ma'am," & vbCrLf & vbCrLf 
    .Body = .Body & "Thanks for your support." & vbCrLf & vbCrLf 
    .Body = .Body & "V/r" & vbCrLf & vbCrLf 
    .Body = .Body & “Scott Smith” 
End With 
Set objMail = Nothing 
Set objOL = Nothing 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
Any assistance would be greatly appreciated.

I did a google search for both old posts, and Excel FAQs, but wasn't able to
find what I am looking for...

Does anyone have a snippet on how to use Excel VBA to grab the current
machine's IP address?

I figure it would be something like Randy Birch's code to grab the currently
logged in user's UserID, but his code is more advanced than I can manage, so
at this point I figure I'm stuck panhandling for a sample for the IP

Thanks in advance,

The enclosed questions or comments are entirely mine and don't represent the
thoughts, views, or policy of my employer. Any errors or omissions are my

I would like to see the ability in Excel to format a cell as an IP address.,
such that each octet could then be changed independenlty of the others as you
you can down a column. This would be for spreadsheets for IP address

Hi there

I created a short program in VBA to send emails to addresses in a list I created in Excel. To avoid the annoying message "A program is trying to automatically send e-mail in your behalf", I'm using sendkeys to actually "press" the button in Outlook. However I found out that this sometimes work, sometimes it doesn't, but I have no idea why this does not work 100%. Below the code.

Sub send_email()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim cell As Range

    Application.ScreenUpdating = False
    Set OutApp = CreateObject("Outlook.Application")

    On Error GoTo cleanup
    For Each cell In Columns("V").Cells.SpecialCells(xlCellTypeConstants)
        If cell.Value Like "?*@?*.?*" And _
           LCase(Cells(cell.Row, "W").Value) = "yes" Then

            Set OutMail = OutApp.CreateItem(0)
            On Error Resume Next
            With OutMail
                .To = cell.Value
                .Subject = "subject"
                .Body = "Olá " & Cells(cell.Row, "U").Value _
                      & vbNewLine & vbNewLine & _
                        "message " & _
                        Cells(cell.Row, "Y").Value & "."
                Application.SendKeys "%s"
                End With
            On Error GoTo 0
            Set OutMail = Nothing
        End If
    Next cell

    Set OutApp = Nothing
    Application.ScreenUpdating = True
End Sub
Can anyone tell me what I did wrong, or any other workaround solution?

Thanks to all


I am able to use Excel VBA to send email from Lotus Notes, but what about being able to create a new task in ToDo? Would appreciate if anyone knows Excel VBA code for that.

I only want to send one worksheet from excel not all the worksheets that I
created at one time, is this possible?

i need some vba to gather a range selected from a filter--i only want the range selected from the whole range...?

thank you.

Hello people,

First time around here. I am not sure I'm on the right newsgroup, so please
redirect me if needed.

Here's my question: I need to be able to search a string from the right in
an Excel-cell. Basically I need to find the last space in a string. I can
find the first space in a string with the find-command but that works only
from left to right. How can I do this from right to left ?

Many thanks,


I have a safe data source, where large files are always stored in a .gz

Is there a way to get excel VBA to open up the .gz file?

In the old old days, there used to be a windows command line that would extract files from a windows zip file, but I can't seem to find that anywhere. There has got to be an automated way to do this....

Thanks very much in advance.


I have a quite specific VBA request - I found how to do it on another website but I can't find it after hours of looking (I should have written it down I know) - what I need is:

VBA to send the same email to multiple addresses (they would be listed in a sheet, say from A1 to A500)

If possible I'd like it to send the message to one address at a time, but automatically, so click 'send' and it goes to the first address, then second, then third, etc..

I would like to be able to type the Subject and the content in cells on the same sheet as the addresses, possibly with some HTML in.

Is any/all of this possible?

Hello all,

I have no experience in Excel VBA before, that's why I tried hard to use a mixture of Excel existing formulas to calculate the accrual sum of revenue for a school's course (with a duration of less than 12 months, and 6 batches of students), and I failed several times to do so

I've heard that we can use Loop in Excel VBA to execute the task easier and more efficiently. I kept searching but my limited knowledge of coding prevented me from success.

Would you please have a look at the attached example, and teach me how to generate a Macro to implement the task. Thanks a lot for your help.

Hi there,

I already use Excel VBA to send emails via Outlook. I need to specify that the email format should be plain text (rather than html or rtf), and that the importance should be "high". Can anyone point me to the tabs / commands / whatever that I need to add to the VBA code in order to do this, please?

I had a look at Ron de Bruin's page but I couldn't see anything on these commands.

Any assistance would be appreciated - thanks!


Within my code I currently have a string input to a function, which is an operator such as >. I am trying to use that operator within the code to return a true or false for a mathematical equation... ie. I currently have 40 & ">" & 30.. and want it to return TRUE. Any ideas? Help would be greatly appreciated!

Added: The best way to explain myself a little better is by a simple example: If I had a function which requires three inputs... two doubles (d1, eg. 40 and d2 eg. 30), and a string which is an operator (s1 eg. ">").... I am effectively writing the following in the code: If d1 & s1 & d2 then do Y etc. So the problem is that the code doesnt recognise that s1 is the operator > and not just a string.


I am trying to add a chart from an excel to outlook.
my chart is in a separate sheet .
Can somebody give a way out of this problem.



I use an excel vba to send out emails with attachments. The body of the message is stored in cells and are formated.

Can I change the default plain text email into rich text and so somehow use and apply the format of the cells to format the body of the email?


Tried to extract a picture from an Excel worksheet and save it as a *.jpg /
*.gif / *.bmp file - don't know how to do. Anyone knows how to do that? Same
goes for Word.

While constructing my SQL query in Excel VBA to bring in data from my access
DB......I need to know how to properly write the sql that do the same as
writng a LEFT JOIN sql query.....
I don't like to use left join, right how would I write it so
it brings in all records from one and only where they match from another?

Quick question. Is there a built in function/command in excel vba to execute a string as if it were part of the program.

MsgBox bob

Now I know execute is not the right function, is there one that does that? In the example above I would like the msgbox to print 1.

Anyone know the command I'm looking for. Thanks!

Hello, i want to delete a string from another string, like the example below:

variable: "daniel" - "niel"

so in my variable i would have "da"

how can i do it??


how to delete duplicated entries from an excel list

No luck finding an answer? You could always try Google.