Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default VBA Function error and display result in sheet

I have the following vba code and the FuncSpaces variable (always
either 9, 10 or eleven spaces) will not concatenate to the other
strings.

Function FuncSpaces(PayGp)

Dim x As String
Dim NoOfSpace As Variant
Set NoOfSpace = Sheets("EmpInfo").Range("Spaces")
Code = 780

If IsEmpty(ActiveCell) Then
Exit Function
End If

x = Application.VLookup(PayGp, NoOfSpace, 2, False)
FuncSpaces = x

End Function

Sub CreatePrn()

Dim EmpNo, PayGp, Code, Prn, EffDate, Sal As String

Range("A2").Select
EmpNo = ActiveCell.Offset(0, 1)
PayGp = ActiveCell.Offset(0, 4)
Code = 780
EffDate = ActiveCell.Offset(0, 5)
Sal = ActiveCell.Offset(0, 6)


Do
Call FuncSpaces(PayGp)

Prn = (PayGp) & (EmpNo) & (NoOfSpace) & (Code) & (EffDate) & (Sal)


ActiveCell.Offset(1, 0).Select

Loop Until IsEmpty(ActiveCell.Offset(0, 1))


End Sub

I have watched all the variables and when the function runs it
displays in watch window as " " but when the sub concatenates
all the variables the spaces arent included.

Also, how do I place each instance of the concatenation in a different
sheet.

ie i want the final result of eg 00512345 7800101200415500 to be
placed into new worksheet, so I can then export as text file.

Your help is much appreciated.

Flick. x
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VBA Function error and display result in sheet

Hi Flick,

Try and replace

Call FuncSpaces(PayGp)

with

NoOfSpace = FuncSpaces(PayGp)


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Felicity Geronimo" wrote in message
om...
I have the following vba code and the FuncSpaces variable (always
either 9, 10 or eleven spaces) will not concatenate to the other
strings.

Function FuncSpaces(PayGp)

Dim x As String
Dim NoOfSpace As Variant
Set NoOfSpace = Sheets("EmpInfo").Range("Spaces")
Code = 780

If IsEmpty(ActiveCell) Then
Exit Function
End If

x = Application.VLookup(PayGp, NoOfSpace, 2, False)
FuncSpaces = x

End Function

Sub CreatePrn()

Dim EmpNo, PayGp, Code, Prn, EffDate, Sal As String

Range("A2").Select
EmpNo = ActiveCell.Offset(0, 1)
PayGp = ActiveCell.Offset(0, 4)
Code = 780
EffDate = ActiveCell.Offset(0, 5)
Sal = ActiveCell.Offset(0, 6)


Do
Call FuncSpaces(PayGp)

Prn = (PayGp) & (EmpNo) & (NoOfSpace) & (Code) & (EffDate) & (Sal)


ActiveCell.Offset(1, 0).Select

Loop Until IsEmpty(ActiveCell.Offset(0, 1))


End Sub

I have watched all the variables and when the function runs it
displays in watch window as " " but when the sub concatenates
all the variables the spaces arent included.

Also, how do I place each instance of the concatenation in a different
sheet.

ie i want the final result of eg 00512345 7800101200415500 to be
placed into new worksheet, so I can then export as text file.

Your help is much appreciated.

Flick. x



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
How do I display the result of a function on seperate worksheet e. Beth Excel Worksheet Functions 3 July 15th 08 05:30 AM
formular result to display text from another sheet Dan Excel Discussion (Misc queries) 2 April 1st 08 12:43 PM
Enter data and display function result in same cell ChrisR Excel Discussion (Misc queries) 1 June 21st 06 12:15 AM
Function displays as text, doesn't return result or error SK_in_Austin Excel Worksheet Functions 2 March 28th 06 07:22 PM
Rounding error in Stdev function result. David K Excel Worksheet Functions 15 January 12th 06 04:19 AM


All times are GMT +1. The time now is 05:46 PM.

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

About Us

"It's about Microsoft Excel"