ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   set text in a cell (https://www.excelbanter.com/excel-discussion-misc-queries/223356-set-text-cell.html)

tripflex

set text in a cell
 
Sub ProjectInfo()
Dim strDescription, strName As String
strName = InputBox("Please enter the PROJECT NAME as you would like it to
appear on all sheets.", "Project Name")
strDescription = InputBox("Please enter the PROJECT DESCRIPTION as you would
like it to appear on all sheets.", "Project Description")

If strName = "" Then GoTo err2
If strDescription = "" Then GoTo err2

Sheet1.Cells(b, 3).Value = strName
Sheet1.Cells(b, 4).Value = strDescription
Exit Sub

err2:
Call MsgBox("You must enter a project name AND description!", vbExclamation,
"Error! Must enter project name AND description")

End Sub


Can anybody tell me why i keep getting an error when i try to run this
script? It says application-defined or object-defined error.


Thanks!!

Per Jessen

set text in a cell
 
Hi

The problem is Cells(b,3)

b is seen as a variable.

If you want to put the text in B3 then use this:

Range("B3").value=StrName

or

Cells(3,2).value=StrName 'Syntax Cells(row, Column number)

Hopes this helps

Regards,
Per



"tripflex" skrev i meddelelsen
...
Sub ProjectInfo()
Dim strDescription, strName As String
strName = InputBox("Please enter the PROJECT NAME as you would like it to
appear on all sheets.", "Project Name")
strDescription = InputBox("Please enter the PROJECT DESCRIPTION as you
would
like it to appear on all sheets.", "Project Description")

If strName = "" Then GoTo err2
If strDescription = "" Then GoTo err2

Sheet1.Cells(b, 3).Value = strName
Sheet1.Cells(b, 4).Value = strDescription
Exit Sub

err2:
Call MsgBox("You must enter a project name AND description!",
vbExclamation,
"Error! Must enter project name AND description")

End Sub


Can anybody tell me why i keep getting an error when i try to run this
script? It says application-defined or object-defined error.


Thanks!!



tripflex

set text in a cell
 
OHHHH okay thanks a ton man!

"Per Jessen" wrote:

Hi

The problem is Cells(b,3)

b is seen as a variable.

If you want to put the text in B3 then use this:

Range("B3").value=StrName

or

Cells(3,2).value=StrName 'Syntax Cells(row, Column number)

Hopes this helps

Regards,
Per



"tripflex" skrev i meddelelsen
...
Sub ProjectInfo()
Dim strDescription, strName As String
strName = InputBox("Please enter the PROJECT NAME as you would like it to
appear on all sheets.", "Project Name")
strDescription = InputBox("Please enter the PROJECT DESCRIPTION as you
would
like it to appear on all sheets.", "Project Description")

If strName = "" Then GoTo err2
If strDescription = "" Then GoTo err2

Sheet1.Cells(b, 3).Value = strName
Sheet1.Cells(b, 4).Value = strDescription
Exit Sub

err2:
Call MsgBox("You must enter a project name AND description!",
vbExclamation,
"Error! Must enter project name AND description")

End Sub


Can anybody tell me why i keep getting an error when i try to run this
script? It says application-defined or object-defined error.


Thanks!!





All times are GMT +1. The time now is 06:53 PM.

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