Following the DRY principle ("Don't repeat yourself"), it's better to have a single source block and to parametrize it differently in the two situations.
You can assign the value of a lisp expression to a variable and use it in the code block as follows:
#+begin_src elisp :exports none :var vvalue=(if (eq org-export-current-backend 'html) 4 3)
(setq vname vvalue)
#+end_src
Here the value is going to be 4 during HTML export, 3 in all other situations (including when pressing C-c C-c in the buffer - org-export-current-backend is nil in that case).
You can use a cond for more complicated situations (e.g. in the following, the value is 4 during HTML export, 2 during LaTeX export and 1 in all other situations):
#+begin_src elisp :exports none :var vvalue=(cond ((eq org-export-current-backend 'html) 4) ((eq org-export-current-backend 'latex) 2) (t 1))
(setq vname vvalue)
#+end_src
but the idea is exactly the same: you use a lisp expression to calculate the value that you want to assign to the variable and you use org-export-current-backend to affect it differently during export.