vba - If not...Else skip -
i found question close mine answer specific question couldn't quite relate mine.
i using if not function populate column has values in , want overwrite values if conditions exist , if don't want leave value how is.
in other words want "else" part of function skip or that... i've tried "null" "skip" , few others no luck.
below portion of code in case it's necessary ignore problems in code isn't finished product basic idea in case needed variables. thank in advance!:
sub reportcomparealta() ' ' reportcomparealta macro ' adds instances column d "alta"
dim varsheeta variant dim varsheetb variant dim varsheetc variant dim strvalue variant dim strrangetocheck string dim irow long dim icol long dim wbka workbook dim wbkb workbook dim wbkc workbook dim counter long set wbka = workbooks.open(filename:="g:\reporting\ah_misse_feb2013.xls") set wbkb = workbooks.open(filename:="g:\reporting\ah_misse_mar2013.xls") set wbkc = workbooks.open(filename:="g:\reporting\reportcompare.xls") set varsheeta = wbka.worksheets("localesmallcontratos") set varsheetb = wbkb.worksheets("localesmallcontratos") set varsheetc = wbkc.worksheets("sheet1") strrangetocheck = "a1:iv65536" debug.print varsheeta = wbkc.worksheets("sheet2").range(strrangetocheck) 'may confusing code here varsheetb = wbkc.worksheets("sheet3").range(strrangetocheck) 'may confusing code here debug.print counter = 0 irow = lbound(varsheeta, 1) ubound(varsheeta, 1) if varsheetb(irow, "b") = varsheeta(irow, "b") & varsheetb(irow, "b") <> "gerencia" & varsheetb(irow, "b").value <> "" & varsheetb(irow, "d") = "alta" strvalue = "" varsheetb.range("irow:b").select selection = strvalue activesheet = varsheetc range("a1").select selection.offset(counter, 0).value = strvalue counter = counter - 1 else "skip" end if next irow
end sub
simply remove else:
if varsheetb(irow, "b") = varsheeta(irow, "b") & varsheetb(irow, "b") <> "gerencia" & varsheetb(irow, "b").value <> "" & varsheetb(irow, "d") = "alta" strvalue = "" varsheetb.range("irow:b").select selection = strvalue activesheet = varsheetc range("a1").select selection.offset(counter, 0).value = strvalue counter = counter - 1 end if
Comments
Post a Comment