Link to home
Start Free TrialLog in
Avatar of Lazarus
LazarusFlag for United States of America

asked on

VB Script Formula problem

Is there a way to change these so that if the Source Cell is empty that they either does nothing or places a vbNullString ? Currently it places a space when there is nothing there.

      DestSheet.Range("I10") = SourceSheet.Cells(0 + Student, 1) & " " & SourceSheet.Cells(0 + Student, 2)
      DestSheet.Range("J11") = SourceSheet.Cells(0 + Student, 2)

Avatar of Dave
Dave
Flag of Australia image

You can test for a string greater than 0 characters in the source cell, ie this code will do nothing if  SourceSheet.Cells(0 + Student, 2).Value) is empty

Cheers
Dave

If Len(SourceSheet.Cells(0 + Student, 2).Value) > 0 Then DestSheet.Range("J11") = SourceSheet.Cells(0 + Student, 2)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lazarus

ASKER

This solution works best for the script I'm working with, when using the If Len script is tends to skip certain fields in the worksheet and is also longer.