Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Inserting variable outputs into different ranges

Without knowing what Pld is, i.e. data type, it is difficult to say. But,
if Pld is a range address then:

If Range(Pld).Value = "G" Then

if Pld is a range object then:

If Pld.Value = "G" Then

Otherwise, if Pld is just a variant variable that holds a data value then it
must not be finding "G" or "H".

Try stepping through the macro using F8 and use the mouse over to see what
value the Pld variable holds at the first If statement. Or put a message
box right after that line and see if you get surprised by what you see.



"Genix" wrote in message
...
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
.
.
.

NextRow8 = Application.WorksheetFunction.CountA(Range("H78:H8 8")) + 1
Cells(NextRow8, 8) = Variable8

ElseIf PId = "H" Then

NextRow1 = Application.WorksheetFunction.CountA(Range("A90:A1 00")) + 1
Cells(NextRow1, 1) = Variable1
.
.
.
.
NextRow8 = Application.WorksheetFunction.CountA(Range("H90:H1 00")) + 1
Cells(NextRow8, 8) = Variable8

Else
MsgBox "Project Database display problem", vbOKOnly,
"Error"

End If




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Inserting variable outputs into different ranges


To JLGWhiz:
Just to show appreciation and say mighty thanks. This community and forum
has been very helpful to me. My VBA project is now up & running.

PId was a variable and I was equating it to a variable that had not yet been
transferred. Its tricky VBA, you need understanding and common sense to
overcome 'your own' errors.

Cheers

"JLGWhiz" wrote:

Without knowing what Pld is, i.e. data type, it is difficult to say. But,
if Pld is a range address then:

If Range(Pld).Value = "G" Then

if Pld is a range object then:

If Pld.Value = "G" Then

Otherwise, if Pld is just a variant variable that holds a data value then it
must not be finding "G" or "H".

Try stepping through the macro using F8 and use the mouse over to see what
value the Pld variable holds at the first If statement. Or put a message
box right after that line and see if you get surprised by what you see.



"Genix" wrote in message
...
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
.
.
.

NextRow8 = Application.WorksheetFunction.CountA(Range("H78:H8 8")) + 1
Cells(NextRow8, 8) = Variable8

ElseIf PId = "H" Then

NextRow1 = Application.WorksheetFunction.CountA(Range("A90:A1 00")) + 1
Cells(NextRow1, 1) = Variable1
.
.
.
.
NextRow8 = Application.WorksheetFunction.CountA(Range("H90:H1 00")) + 1
Cells(NextRow8, 8) = Variable8

Else
MsgBox "Project Database display problem", vbOKOnly,
"Error"

End If





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Named ranges scope / workbook/worksheet level named ranges- changeswith variable use... christian_spaceman Excel Programming 3 December 24th 07 01:15 PM
Counting variable ranges and auto-summing variable ranges Father Guido[_5_] Excel Programming 2 March 29th 06 04:07 AM
Using variable name as a value for inserting a row T8RSP[_2_] Excel Programming 3 November 7th 05 09:14 AM
inserting a variable into VB edb Excel Programming 2 February 29th 04 12:39 PM
Inserting a File Name into Worksheet Ranges Chris Excel Programming 0 October 1st 03 04:37 AM


All times are GMT +1. The time now is 01:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"