How to adapt my VBA code which will update column choosing only the empty cells, not all from the beginning

ODSCm

New Member
Joined
Dec 18, 2020
Messages
32
Office Version
  1. 2016
Platform
  1. Windows
Hello Dear friends.

I have a macro which brings data from an external application using a loop.
Think that external application has two olumns which is vehicle, and vehicle delivery date. My excel has the same two columns. So it brings vehicle delivery date information from the external application matching the vehicle numbers with external application. When I run the macro, it starts from the beginning until to last row with vehicle number in Excel, no matter if the vehicles have already vehicle delivery date, So it rewrites.
What I want my Macro to consider only the vehicle which does not have vehicle delivery date, which means blank cell in vehicle delivery date column. So that it will skip the vehicles with delivery date. Therefore it will be not working in every update from the beginning rewriting again.

I am using the following code block currently. As I said it working directly from the beginning. What kind of change should I do to make it work as I explained?

for i= 2 To Range ("A2").End(xIdown). Row x 'starts loop from second row from cell A2
vehicleno = i
screen.putstring vehicleno 2, 70 'put the vehicleno from excel to application and press enter
screen.SendKeys ("<enter>")

vehicledeliverydate = screen.getstring(15,19,56) 'for vehicle delivery date info is taken from external application
datenblatt.Cells(i,2).Value = vehicledeliverydate ' past the deliverydate info which is taken from external application to excel from B2

Next i
Columns("a:z").EntireColumn.Autofit
MsgBox ("Datenabfrage beendet!")
End Sub


Thanks in advance for help
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
date is in column B right? add at the begining of for loop:

VBA Code:
if Range("b" & i).Value <> "" then
' your copy code
end if
 
Upvote 0
date is in column B right? add at the begining of for loop:

VBA Code:
if Range("b" & i).Value <> "" then
' your copy code
end if
Thanks MrTomasz, I will try and share the result.
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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