• 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

Import data and numbers|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Import data and numbers|VBA & Macros|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
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 & MacrosImport data and numbers
sp_PrintTopic sp_TopicIcon
Import data and numbers
Avatar
Cristina González
Member
Members
Level 0
Forum Posts: 29
Member Since:
November 16, 2019
sp_UserOfflineSmall Offline
1
September 5, 2021 - 12:30 am
sp_Permalink sp_Print

Hello,

I have a problem with one of the macros I've recently created. 

Every morning I get an excel file (.xls) with some data. From the main excel file, called Deljit_Renault.... I import the data of the first file. The problem is that in this data, there are some numbers that have more than three figures and when this is imported, they are not copy as it should. For instance, if the original number is 1200 it is copy as 1,2. Could anyone help me to solve this problem?

 

Sub ImportData()
Dim OpenBook As Workbook
Dim FileToOpen As Variant
Dim LastRow As Long
Dim LastRowTemp As Long
Dim Hoja1 As Worksheet
Dim PT_Deljit As PivotTable
Dim PT_Fecha As PivotTable

Call Entry_Point

FileToOpen = Application.GetOpenFilename(Filefilter:="Excel files (*.xls),*.xls", Title:="Select Workbook to Import")

If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)

'Locate last empty row in temporary file
LastRowTemp = Range("B" & Rows.Count).End(xlUp).Row

'copy the info in the openbook

OpenBook.Sheets(1).Range("B5:x" & LastRowTemp).Copy

'Locate last empty row in Deljit file

LastRow = ThisWorkbook.Sheets("PegarAquiLaJitK").Range("B" & Rows.Count).End(xlUp).Row + 2

ThisWorkbook.Worksheets("PegarAquiLaJitK").Range("B" & LastRow).PasteSpecial Paste:=xlPasteValues
OpenBook.Close

End If

ThisWorkbook.RefreshAll
ThisWorkbook.Sheets("Precarga").Select

Call Exit_Point

Set PT_Deljit = ActiveSheet.PivotTables("Tb_Deljit")
Set PT_Fecha = ActiveSheet.PivotTables("Tb_Fecha")
PT_Fecha.PivotCache.Refresh
PT_Deljit.PivotCache.Refresh

End Sub

I also attach the two files.

Thanks a lot,

Cristina

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 414
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
2
September 8, 2021 - 4:13 am
sp_Permalink sp_Print

i  assume at some point the data was in a csv file?

i would check how the file is being imported and see if it is being converted due to the comma delimiter.

if you still cant get it to work, as a nasty work around you could run a loop on that column like the below

Sub FixThousands()

Dim xCol As Range
Dim xCell As Range

Set xCol = Range("l:l")

For Each xCell In xCol

If InStr(xCell.Value, ".") > 0 Then
xCell = xCell.Value * 1000
End If

Next xCell

End Sub

Avatar
Cristina González
Member
Members
Level 0
Forum Posts: 29
Member Since:
November 16, 2019
sp_UserOfflineSmall Offline
3
September 9, 2021 - 2:16 am
sp_Permalink sp_Print

Hello Purfleet,

I thought the worksheets were uploaded... yes, you are right, I get the file to be imported from SAP and it is not an .xlsm.

Anyway, your solution works perfect. Thanks so much.

Best,

Cristina

PD: I am trying to upload the files just in case it is of any help for anyone else.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Catalin Bombea, John Kobiela, Malcolm Sawyer
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.