ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Alpha Numerics bunch together (https://www.excelbanter.com/excel-programming/441228-alpha-numeric%E2%80%99s-bunch-together.html)

Rob

Alpha Numerics bunch together
 
Hi,

When I type code the alpha numerics sometimes bunch together and the font
changes to red as in the case below. As in For i =1To2 and Nexti .

Sub CopyDemand()
Dim i As Integer
For i =1To2
Sheets("Demand").Select
ActiveCell.Offset(0, 2).Activate
ActiveCell.Copy
Sheets("Demand1").Activate
ActiveCell.Offset(0, 1).Activate
ActiveCell.PasteSpecial
Nexti
End Sub

Being a newbie at VBA programming I am sure there is a very simple
explanation for this.

Please will someone tell me what is happening.

Thank you.


OssieMac

Alpha Numerics bunch together
 
Hi Rob,

Just insert some spaces between the words/numbers. VBA thinks it is one
string when the delimiter spaces are not included.

Example
For i = 1 To 2

With some code like endif VBA is smart enough to insert the spaces for you
and change it to End If but this does necessarily occur with all code.


--
Regards,

OssieMac


"Rob" wrote:

Hi,

When I type code the alpha numerics sometimes bunch together and the font
changes to red as in the case below. As in For i =1To2 and Nexti .

Sub CopyDemand()
Dim i As Integer
For i =1To2
Sheets("Demand").Select
ActiveCell.Offset(0, 2).Activate
ActiveCell.Copy
Sheets("Demand1").Activate
ActiveCell.Offset(0, 1).Activate
ActiveCell.PasteSpecial
Nexti
End Sub

Being a newbie at VBA programming I am sure there is a very simple
explanation for this.

Please will someone tell me what is happening.

Thank you.



All times are GMT +1. The time now is 07:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com