vba - If Statement is not functional -


hello stuck code, don't know whats wrong if statement keeps displaying t1t on every sheet. please help. thank you.

public sub commandbutton4_click()  dim sheet worksheet dim integer  = 2 activeworkbook.worksheets.count    set sheet = activeworkbook.worksheets(i)    if sheet.name = "usa" & , range("d20").value = "branch codes"      sheet.cells(2, 1).value = "b1"    else      sheet.cells(2, 1).value = "t1t"    end if  next  end sub 

you want set sheet.range("d20") if want read given sheet. otherwise, refer d20 on first sheet.

if sheet.name = "usa" & , sheet.range("d20").value = "branch codes" 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -