muhammad susanto
Well-known Member
- Joined
- Jan 8, 2013
- Messages
- 2,102
- Office Version
- 365
- 2021
- Platform
- Windows
hi all..
the code working well to pull data from multiple sheets (all sheet) into 1 sheet in the same workbook.
i want to modified can pull data with specific name sheet and specific cell
my question like this
1. my target in sheet "Master" start col B9 down right till K13 with my data (will be pulled) in sheet "Summary & Country" in cell with number "yellow" shading (rows KEEP IN THERE - not change rows)
2. i want to pull data from sheet "summary & country" into sheet "master" based on name of city/country like Hongkong, Bangkong, UsA....etc
3. my desired result in sheet "master" with criteria:
- if in cell A9 is Hongkong -- pull data from sheet "summary & country" into sheet 'master" and placing in cell B9 till K9.
- if in cell A10 is Bangkok -- pull data from sheet "summary & country" into sheet 'master" and placing in cell B10 till K10.
- if in cell A11 is USA -- pull data from sheet "summary & country" into sheet 'master" and placing in cell B11 till K11.
- etc...
4. i want when running macro, at first show msg box "select city...." then run/click ok
5. for sample please, check in my first OP
this my link file Loading Google Sheets
across posting VBA : Pull Data From Multiple Sheet Into 1 Sheet Based On Criteria
thank you
the code working well to pull data from multiple sheets (all sheet) into 1 sheet in the same workbook.
i want to modified can pull data with specific name sheet and specific cell
VBA Code:
Sub Consolidate_Worksheets_To_Master_Using_Arrays()
Dim ws As Worksheet
Dim sh As Worksheet
Dim a As Variant
Dim i As Long
Dim r As Long
Application.ScreenUpdating = False
Set sh = ThisWorkbook.Worksheets("master")
sh.Range("B9").CurrentRegion.Offset(1).ClearContents
r = 2
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "master" And ws.Name <> "etc.." Then
With ws
a = Array("G10", "H10", "J10", "I2", "I9")
For i = LBound(a) To UBound(a)
a(i) = .Range(a(i)).Value
If i >= 100000 Then a(i) = Val(AlphaNum(CStr(a(i))))
Next i
sh.Range("A" & r).Resize(, UBound(a) + 1).Value = a
r = r + 1
End With
End If
Next ws
Application.ScreenUpdating = True
End Sub
Function AlphaNum(txt As String, Optional numOnly As Boolean = True) As String
With CreateObject("VBScript.RegExp")
.Pattern = IIf(numOnly = True, "\D+", "-?\d+(\.\d+)?")
.Global = True
AlphaNum = .Replace(txt, "")
End With
End Function
1. my target in sheet "Master" start col B9 down right till K13 with my data (will be pulled) in sheet "Summary & Country" in cell with number "yellow" shading (rows KEEP IN THERE - not change rows)
2. i want to pull data from sheet "summary & country" into sheet "master" based on name of city/country like Hongkong, Bangkong, UsA....etc
3. my desired result in sheet "master" with criteria:
- if in cell A9 is Hongkong -- pull data from sheet "summary & country" into sheet 'master" and placing in cell B9 till K9.
- if in cell A10 is Bangkok -- pull data from sheet "summary & country" into sheet 'master" and placing in cell B10 till K10.
- if in cell A11 is USA -- pull data from sheet "summary & country" into sheet 'master" and placing in cell B11 till K11.
- etc...
4. i want when running macro, at first show msg box "select city...." then run/click ok
5. for sample please, check in my first OP
this my link file Loading Google Sheets
across posting VBA : Pull Data From Multiple Sheet Into 1 Sheet Based On Criteria
thank you