Consulting

Results 1 to 5 of 5

Thread: Offset in a double nested loop.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Question Offset in a double nested loop.

    Hi! I'm a beginner trying to learn VBA and am running into issues. Please try to keep your coding corrections basic and similar to what I have down! I'm not skilled enough to get ~fancy~ yet.

    Here is the goal of the code:

    "You are going to code a function that transcribes the array to reveal the hidden message I have arranged and output it into a cell that I designated. Make a nested loop with the outer loop counting from 1 to 7 using the variable i. The inner loop will count from 1 to 14 using the variable j. Let the variable Number get the values for cells from left to right then proceed down (i.e. Number = ActiveCell(i,j).value or some variant starting at A1). Then, on the inside loop make if statements that says
    IF:
    a. Number = 4 Then Letter = D
    c. Number = 19 Then Letter = S
    d. Number = 12 Then Letter = L
    e. Number = 16 Then Letter = P... and so on
    Next, make the variable Word be the sum of the variable Letter after every inside iteration. Note, the variable Word needs to be reset after every iteration of i. Finally, output the variable Word into cells A10:A16 for each i. This problem tests your knowledge on coding nested loops, if functions, usage of dimensions, and order of operations."

    I mostly get a mismatch error on the bolded line, but the values in the sheet are numbers. If I don't get a mismatch error, I get that it's out of range. I get the first line to go in A10, but I cant get anything after that. Please help! Also can someone let me know if I'm able to do an offset with two variables? (i.e. offset(i, j)).Image 3-26-20 at 9.34 AM.jpgImage 3-26-20 at 9.36 AM.jpg
    Last edited by momsfavson; 03-26-2020 at 09:20 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •