How to compare two strings in different workbooks (Excel VBA) -


to keep simple: need match userid number 1 excel workbook another. idea see if larger of 2 documents has userid number smaller document. if larger document has userid number, other data needs copied on smaller document (i know how this)

my problem when compare each field, function keeps displaying searchstring (the string in larger document) blank. not picking on array have created picks on 1 created in smaller document. code explain better me. not programmer nor know vba, know code sub-par.

whenever test code, have msgbox function show me strings comparing, reason, "searchstring" shows blank comparing "findstring" has data needs, blank string whatever reason. need msgbox function show array data other document, not blank box.

'nid comparisson script  sub getuid()  'select appropriate cell range("c2").select  'count number of rows contain data in sccm document. dim rows integer rows = activesheet.usedrange.rows.count  'create array sheets("smsreportresults(2)")     arrdata = .range(.cells(2, 3), .cells(rows, 3)).value end  'declare variable comparing uid/nid strings dim findstring string  'loop through document , grab uid numbers "searchstring" = 1 rows - 1     findstring = arrdata(i, 1)     windows("nids.xlsx").activate     dim rows2 integer     rows2 = activesheet.usedrange.rows.count      'create second array in nids workbook     sheets("sheet1")         arrdata2 = .range(.cells(2, 1), .cells(rows, 1)).value     end      'create searchstring nids workbook     dim searchstring string      j = 1 rows2 - 1         searchstring = arrdata2(j, 1)          dim compare integer         compare = strcomp(searchstring, findstring)         msgbox (seachstring)         msgbox (findstring)         msgbox (compare)         activecell.offset(1, 0).select      next next  end sub 

go top of module , type "option explicit". misspelled searchstring inside "msgbox (seachstring)" , therefore created new variable.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -