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.
there is another which direct import without using key and gid but it will then add row into alt+enter data instead
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
Last edited by a moderator: