VBA Code to skip cells which has data

exceluser9

Active Member
Joined
Jun 27, 2015
Messages
388
Hi Team,

I have a data in column A, B, C and D and I have written VBA code to pick results in column G,H and I and I get the data but in B6, G6, D6, B8, C8 and D8 isnt with data and the same hasnt appeared in G6, H6, I6, G8, G8 and I8 and when i input the data in B6, G6, D6, B8, C8 and D8 and run the macro for second time it has to run only for blank cells and it has to skip the cells which is already with data and its has to happen whenever i run it, it should fill only blank cells and not the rest. VBA code below. Please could you help

Sub Macro1()
'
' Macro1 Macro
'
'
Sheets("Sheet1").Select
Range("G2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],C1:C4,2,0)"
Range("H2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-2],C1:C4,3,0)"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-3],C1:C4,4,0)"

LRN = Range("F" & Rows.Count).End(xlUp).Row
Selection.End(xlDown).Select
Range("G2:G" & LRN).Select
Range(Selection, Selection.End(xlUp)).Select
Range("G2:G" & LRN).Select
Selection.FillDown
Range("G2:I" & LRN).Select
Selection.End(xlUp).Select


Range("G2:I" & LRN).Select
Range(Selection, Selection.End(xlUp)).Select
Range("G2:I" & LRN).Select
Selection.FillDown
Range("G2:I" & LRN).Select
Selection.End(xlUp).Select
Range("J2").Select
End Sub




DATA RESULT
COLUMN ACOLUMN BCOULMN CCOLUMN DCOLUMN FCOLUMN GCOULMN HCOLUMN I
NAMENUMBERAGERANKNAMENUMBERAGERANK
DAVID12310GOODDAVID12310GOOD
ALWIN676711POORALWIN676711POOR
GEORGE GEORGE
ALFRED76713BADALFRED76713BAD
WILSON WILSON

<tbody>
</tbody><colgroup><col><col><col><col><col><col><col><col><col></colgroup>
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
How about
Code:
Sub Macro1()
   Dim LRN As Long
   LRN = Range("F" & Rows.Count).End(xlUp).Row
   Range("G2:G" & LRN).SpecialCells(xlBlanks).FormulaR1C1 = "=VLOOKUP(RC[-1],C1:C4,2,0)"
   Range("H2:H" & LRN).SpecialCells(xlBlanks).FormulaR1C1 = "=VLOOKUP(RC[-2],C1:C4,2,0)"
   Range("I2:I" & LRN).SpecialCells(xlBlanks).FormulaR1C1 = "=VLOOKUP(RC[-3],C1:C4,2,0)"
   Range("J2").Select
End Sub
 
Upvote 0
Please do not post the same question multiple times. (rule 12 here: Forum Rules).
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,449
Members
449,083
Latest member
Ava19

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