• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Simple string body to display in an email|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Simple string body to display in an email|VBA & Macros|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosSimple string body to display in an…
sp_PrintTopic sp_TopicIcon
Simple string body to display in an email
Avatar
Roger Anderson

New Member
Members
Level 0
Forum Posts: 1
Member Since:
May 2, 2023
sp_UserOfflineSmall Offline
1
May 2, 2023 - 3:06 am
sp_Permalink sp_Print sp_EditHistory

Good Afternoon,

I am having a terrible time writing a simple string body that pulls information from Excel workbook columns.

I've even tried copying the format from a macro that I wrote with similar functionality but it still doesn't work -even after I've change the lines of the string (code).

The Macro is named 'FedexinfoToSite on the attached workbook

Help and thanks in advance

Avatar
Hans Hallebeek
the Netherlands
Member
Members
Level 0
Forum Posts: 121
Member Since:
October 17, 2018
sp_UserOfflineSmall Offline
2
May 2, 2023 - 4:34 pm
sp_Permalink sp_Print

Hi Roger, you should keep in mind when attaching a file with data links you make sure they work for others.

We do not have access to the connection at your shareppoint sciuusa etc...

Your question is about the macro but a file that first needs to braek links or skip updates is a P in the A when trying to help

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1529
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
3
May 4, 2023 - 10:45 am
sp_Permalink sp_Print

Hi Roger,

You haven't actually said what the problem is, and any error that VBA generated would assist in finding the issue.

However after running the code I can see VBA gives a type mismatch error which indicates that, as you are trying to build a string, you are using something that isn't a string.

Looking at your code I see you are trying to include the FedEx tracking number in the string, but this is a number.

To make the code work you need to cast the number to the string type using the CStr function

strbody = "Good Afternoon " + Cells(I, 17).Value + "," _
& vbNewLine & vbNewLine _
& "The above's Fedex tracking number is " + CStr(Cells(I, 27).Value) + _
vbNewLine & vbNewLine & vbNewLine & vbNewLine _
& "Regards,"

Regards

Phil

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 648
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
4
May 4, 2023 - 5:30 pm
sp_Permalink sp_Print

Or use & consistently rather than + for concatenation. 🙂

The following users say thank you to Velouria for this useful post:

Philip Treacy
Avatar
Hans Hallebeek
the Netherlands
Member
Members
Level 0
Forum Posts: 121
Member Since:
October 17, 2018
sp_UserOfflineSmall Offline
5
May 5, 2023 - 3:56 pm
sp_Permalink sp_Print

Use Cells(I, 27).Text  instead

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online:
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 216
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Melanie Ford
Isaac Felbah
Adele Glover
Hitesh Asrani
Rohan Abraham
Anthony van Riessen
Erlinda Eloriaga
Abisola Ogundele
MARTYN STERRY
Rahim Lakhani
Forum Stats:
Groups: 3
Forums: 24
Topics: 6356
Posts: 27793

 

Member Stats:
Guest Posters: 49
Members: 32324
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.