View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Genix Genix is offline
external usenet poster
 
Posts: 8
Default Inserting variable outputs into different ranges

Hello,

As simple as it may seem, I require some help.
I have used userforms to collect information from the user and stored them
in "public declared variables". So using the break point I see that the value
of each declared variable is retained.

I have a worksheet with eight ranges (each Range has ten rows and eight
columns); each column is to hold a separate piece of information. I want VBA
to transfer the info in those variables to the ranges for every session.


When I execute the sub it gets to a point and jumps right to the last Else
statement popping up the message box. I do not know why but it keeps skipping
the IF . . Then ... ElseIf construct.

I know its a clumsy route I took, does anyone have some valuable assistance
to provide? Thank you

Here is the relevant section of the code:

Worksheets("project Database").Activate

IF PId = "G" Then

(€˜This determines the next empty row within the range)
NextRow1 = Application.WorksheetFunction.CountA(Range("A78:A8 8")) + 1

(€˜This transfers the variable)
Cells(NextRow1, 1) = Variable1

NextRow2 = Application.WorksheetFunction.CountA(Range("B78:B8 8")) + 1
Cells(NextRow2, 2) = Variable2

NextRow3 = Application.WorksheetFunction.CountA(Range("C78:C8 8")) + 1
Cells(NextRow3, 3) = Variable3