how do I make code more readable ?

hi Experts
I have a really long line of code:

sheets("Personal Format Presentation").Range("B21").value = Range("A21").value & " " & Range("C21").value & Range("D21").value

How Can I make this easier to read ?

Hope that makes sense !

Sandra

Almir's picture

how do I make code more readable ?

I am not sure, but you could try to create named ranges (across the workbook) from affected cells and then refer to those names instead of long line of code.

Nick's picture

hi Sandra.. there are a few

hi Sandra.. there are a few things you can do.. these are prob the best:

1. Use line continuation:

sheets("Personal Format Presentation").Range("B21").value = _
 Range("A21").value & " " & Range("C21").value & Range("D21").value

2. Split up into more lines:

set PFP = sheets("Personal Format Presentation")
Variable1 = Range("A21").value
Variable2 = Range("C21").value
Variable3 = Range("D21").value
 
PFP.Range("B21").value = Variable1 & " " & Variable2 & Variable3

Nick