Import Data from Google Sheet char(10) missing

tendosai

New Member
Joined
Mar 14, 2022
Messages
26
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
i actually wanna exactly copy&pasted what appear in google spreadsheet into my excel without touching anything using VBA. here is my sheet Sample Sheet
i google and get some code but they appear to be error on char(10). as you can see that my data have alt+enter or char(10) in there.
for example this code (credit to MikeMoy here is the original) import so perfectly except all the alt+enter data will move into single line. :(
VBA Code:
Sub importGsheetLads()

 Dim keyString As String
 Dim gidString As String
 Dim sheet As Sheets
 Dim ws As Worksheet
 Dim wb As Workbook
 Dim Rng As Range
 Dim InputRng As Range, ReplaceRng As Range
 '' change the below keyString and gidString values as required
 keyString = "1ImWTTFhKV0UwZVDRKI35udBPmwZowxTwkWcyT8Sg0xE"
 gidString = "0"
 '' //////////
 
 For Each ws In Worksheets
    If ws.Name = "Raw_Report" Then
        Application.DisplayAlerts = False
        Sheets("Raw_Report").Delete
    End If
Next
Sheets.Add(After:=Sheets(Sheets.Count)).Name = "Raw_Report"
     With ActiveSheet.QueryTables.Add(Connection:="URL;[URL]https://spreadsheets.google.com/tq?tqx=out:html&tq=&key=[/URL]" & keyString & "&gid=" & gidString, Destination:=Range("$A$1"))
        .Name = "q?s=goog_2"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingNone
        .WebTables = "1,2"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
there is another which direct import without using key and gid but it will then add row into alt+enter data instead
 
Last edited by a moderator:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,223,888
Messages
6,175,215
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top