vba question

  Josquius 18:33 19 Jan 05

I have dim hello(100) as integer before my sub then in my sub I have

for hello(0 to 100) Worksheets("lemon").Cells(2,1).value= worksheets("lemon").cells(1,1) however this does not work. I get a syntax error. What have I done wrong? I have never used multiple integers in this way before. I get a sytax error with to highlighted however VBA itself told me to put that there.

  VoG II 18:37 19 Jan 05

I don't understand what this code is meant to do.

The correct syntax for a For statement is

For hello = 0 To 100

Worksheets("lemon").Cells(2, 1).Value = Worksheets("lemon").Cells(1, 1)

Next hello

  VoG II 18:39 19 Jan 05

If you Dim hello(100)

the elements of the array will be hello(0) to hello(99) unless you use Option Base 1 at the top of the module, in which case they will run from hello(1) to hello(100)

  Josquius 18:43 19 Jan 05

I made a mistake originally, it isn't 2,1 and 1,1 its 2, hello and 1,hello.
Doing what you said despite this I get a type mismatch with it identified as a integer before hand and syntax error without.

  VoG II 18:50 19 Jan 05

Dim hello(1 To 100) As Integer

Dim i as integer

For i = 1 To 100

Worksheets("lemon").Cells(2, hello(i)).Value = Worksheets("lemon").Cells(1, hello(i))

Next i

  VoG II 20:10 19 Jan 05

I'm still puzzling over what you are wanting to do. If you just want to copy the contents of A1:A100 to B1:B100

For i = 1 To 100

Worksheets("lemon").Cells(2, i).Value = Worksheets("lemon").Cells(1, i).Value

Next i

This thread is now locked and can not be replied to.

How to get Windows 10 for free | How to install Windows 10: There is still a way to avoid paying…

1995-2015: How technology has changed the world in 20 years

Alex Chinneck’s giant ice cube Christmas tree at Kings Cross

Apple rumours & predictions 2017: The iPhone 8, new iPads, and everything else you should expect fr7…