I need to find latitudes and longitudes for companies that have a value of 0 based on zip code in Microsoft Excel using VBA -


I have a master sheet with all the zip codes and each zip code has related latitude and longitude.

A ???? B. A???? CA???? D â ????

A ???? 20812 one 38.96837 one-77.14141 one ????

A ???? 20813 One 38.96451 One-77.0878 9 One ????

A ???? 20814 A 39.00824 A-77.0 9 76 One ????

A ???? 20815 a 38.98761 an -77.06 9 6 a ????


But pastestate already has some values, prefilled.

A ???? D â ???? E F ????

A ???? 20812 one 38.96837 one-77.14141 one ????

A ???? 20813 A 0 A ???? 0 one ????

A ???? 20814 A 39.00824 A-77.0 9 76 One ????

A ???? 20815 a 0 a ???? 0 one ????

Paste sheet already has data about zip latitude and long time but in some places latitude and long time, 0 already exists.


The code needs to be implemented to change:

  1. Repeat and paste through the paste sheet.
  2. when If you are facing a 0, then compare zipper with pastestate to masterstreet
  3. If the match is found, copy the values ​​of the late and make a long time in the pastestate with the master
  4. And leave it and leave it.

    The pastestate is the place where I have to paste the latitude and the trees when 0 have to face.


    Just to let you know, I do not have a complete programming experience and I have not used VBA before, so this is my first time writing code in VBA.

    So far it has the code that came with me: <<> Sub-lat long () Dim lat_sh1 range dims long_sh1 as range dim dim zip_sh1 range dim zip_sh1 as range dim dim zip_sh2 Range dim lat_sh2 range dims long_sh2 range in the form of slow cell range as a slow dim sheet, worksheet as a slow paste sheet in the form of worksheets 'set lat_sh1 = sheet 1. range ("E2: E970")' Set long_sh1 = Sheet 1.Range ("F2: F970") '' Set zip_ship1 = Sheet 1.Range ("D2: D970") '' Set zip_sh2 = Sheet2 Set length_sh2 = Sheet2.Range ("D1: D99929") 'Set Master Sheet = Sheets (2) Paste' set ("B1: B99929") '' set lat_sh2 = Sheet2.Range ("C1: C99929") " Sheet = Set Sheets (1) For each cell in the pastestate category ("E2: E970") if IsEmpty (cell.Value) or cell.Value = 0 then exit for the end

    To follow the comments of the scam, I use an index / match. After setup, in Sheet 1, where you want to Let's use the latitude to make this formula in column J (which I'm assuming is currently empty, but this will be the new zip code

      = if (or (D2 = 0, D2 = ""), Index (sheet 2! $ B $ 2: $ B $ 99929, Match (E2 and F2, Sheet 2! $ C $ 2: $ C $ 99929 and Sheet2! $ D $ 2: $ D $ 99929,0), 1) , D2)   

    Press Ctrl + Shift + Enter when you complete the formula, because it will need to be an array, because you need to see a combined latitude combined Latitude-Lone column Alternatively, create an important column in sheet two column A which does this (like late and lone), then you can use a normal vlookup instead of array index / match.

    Alternatively, you can do this in VBA, and change the zip code to Sheet 1. sub lathing () dim lat_sh1 range dim dimshsh range as slow_sh1 range dim zip_sh1 range dim dims as zip_sh1 lat_sh2 range long long_sh2 range as dim-range range as slow cell counter Worksheet as a long dim masthead in the form of a slow paste sheet 'set lat_sh1 = Sheet1.Range ("E2: E970")' 'S Long Long 1Shot 1.Range ("F2: F9 Set "zip_ship1 = sheet 1.ange (" D2: D970 ") set to zip_sh 2 = sheet 2. range (" B1: B99929 ") Set length = 2 = Sheet 2 range ("C1: C 99 9 229") long_sh2 = Sheet2.Range ("D1: D99929") String set as 'dim curls' string slow currLon master sheet = Sheets (2 ) Set paste sheet = Sheets (1) PasteSheet.Range ("D2: D970") for each cell if IsEmpty (cell.Value) or cell.Value = 0 then curlLat = cell.offset (0,1) .value CurrLon = cell.offset (0,2) .value cell value = evaluate ("= index (sheet 2! B1: b99929, match (" & amp; curt & amp; curlon & amp; Sheet 2! C1: C99929 & amp; Sheet2! D1: D99920,0) ") End if the next closing sub

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -