Hello excel world.
I have a problem.
I received updated data from excel web, through power queries table.
Every week the data updates selective rows, depending on the time of the month etc.
Example:
Each row of data represents a worksheet historical data.
Example:
Now my problem here is this: when I run macro code. it copies and paste the newly selective data from power queries table.
But it also copies and paste the old data as well and make a duplicated row.
Example:
How can I modify code to prevent this from happening?
See Code below:
Sub Update_Sheets()
Dim i As Integer
Dim j As Integer
Dim country As String
Dim column1 As String
Dim last As Double
i = 1
Worksheets("PMI").Activate
Range("A1").Activate
Do While (IsEmpty(ActiveCell.Offset(i, 0).Value) = False) 'Cycles through each row on the PMI Tab
country = ActiveCell.Offset(i, 0).Value
column1 = ActiveCell.Offset(i, 1).Value
last = ActiveCell.Offset(i, 2).Value
country = strQuote & country & strQuote
Worksheets(country).Activate
Range("B2").Activate
j = 1
Do While IsEmpty(ActiveCell.Offset(j, 0).Value) = False 'cycles through rows on the country sheet to find the first empty row
j = j + 1
Loop
ActiveCell.Offset(j, 0).Value = column1
ActiveCell.Offset(j, 1).Value = last
i = i + 1
Worksheets("PMI").Activate
Range("A1").Activate
Loop
Worksheets("PMI").Activate
End Sub
I have a problem.
I received updated data from excel web, through power queries table.
Every week the data updates selective rows, depending on the time of the month etc.
Example:
Each row of data represents a worksheet historical data.
Example:
Now my problem here is this: when I run macro code. it copies and paste the newly selective data from power queries table.
But it also copies and paste the old data as well and make a duplicated row.
Example:
How can I modify code to prevent this from happening?
See Code below:
Sub Update_Sheets()
Dim i As Integer
Dim j As Integer
Dim country As String
Dim column1 As String
Dim last As Double
i = 1
Worksheets("PMI").Activate
Range("A1").Activate
Do While (IsEmpty(ActiveCell.Offset(i, 0).Value) = False) 'Cycles through each row on the PMI Tab
country = ActiveCell.Offset(i, 0).Value
column1 = ActiveCell.Offset(i, 1).Value
last = ActiveCell.Offset(i, 2).Value
country = strQuote & country & strQuote
Worksheets(country).Activate
Range("B2").Activate
j = 1
Do While IsEmpty(ActiveCell.Offset(j, 0).Value) = False 'cycles through rows on the country sheet to find the first empty row
j = j + 1
Loop
ActiveCell.Offset(j, 0).Value = column1
ActiveCell.Offset(j, 1).Value = last
i = i + 1
Worksheets("PMI").Activate
Range("A1").Activate
Loop
Worksheets("PMI").Activate
End Sub
Countries Indicators #1 NSB (1).xlsm
drive.google.com