LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Problem with code used in other countries

Hi I created a file which basically acts as a price builder.

This has now been distrubted through out our European offices and the USA.

One of the modules alllows the user to select a couple of categories and
then you hit a button and it will create a new workbook with the relevant
pricing information.

It seems that the code reports an error and I am wondering if its due to the
fact that the information is pasted to the new workbook on Sheet1. Obvisously
sheet1 will be Tabelle1 for Germany and I think its Hoja1 for Spain.

How can I change the macro below to check for the language and then use the
appropirate name for the sheet.

I have seen an example below

Country_Code = Application.International(xlCountryCode)
If Country_Code = 49 Then


For each instance of Sheet1 use Tabelle1

My offending code is below

Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Sub CopySelectedColumns()
Dim wbA As Workbook
Dim CopyToWb As Workbook
Dim RateCell As Range
Dim Cur As Range

Dim myRng As Range
Dim myCopy As String
Dim Wks As Worksheet

Set Wks = Worksheets("PriceLists")

myCopy = "P2,Q2"
With Wks
Set myRng = .Range(myCopy)

If Application.CountA(myRng) < myRng.Cells.Count Then
MsgBox "Please fill in Customer Level and Currency!"
Exit Sub
End If
End With


Set wbA = ThisWorkbook
SelectedCol = Range("P2").Value
fCol = Range("B1:N1").Find(what:=SelectedCol, _
Lookat:=xlWhole).Column


Set CopyToWb = Workbooks.Add
'("\\Mcuk-adc\Sales\Prices\PriceTemp.xlt")
Set RateCell = wbA.Worksheets("PriceLists").Range("R2")
Set Cur = wbA.Worksheets("PriceLists").Range("Q2")

wbA.Worksheets("PriceLists").Columns(1).Copy _
CopyToWb.Worksheets("Sheet1").Range("A1")
wbA.Worksheets("PriceLists").Columns(fCol).Copy _
CopyToWb.Worksheets("Sheet1").Range("B1")
CopyToWb.Worksheets("Sheet1").Range("A2") = _
fOSUserName & ", " & Now()


'Do
Customer = InputBox("Enter customer name", "Regards, EW")
'Loop Until Customer < ""
If Customer = False Then
MsgBox "Ok, try later"
ActiveWindow.Close savechanges:=False

End If

If Customer = True Then
Else
CopyToWb.Worksheets("Sheet1").Range("A1") = Customer

LastRow = CopyToWb.Worksheets("Sheet1").Range("B" & Rows.Count).End(xlUp).Row

Cur.Copy
CopyToWb.Worksheets("Sheet1").Range("B2").PasteSpe cial _
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

RateCell.Copy
CopyToWb.Worksheets("Sheet1").Range("B2:B" & LastRow).PasteSpecial _
Paste:=xlPasteValues, Operation:=xlMultiply, SkipBlanks:= _
True, Transpose:=False
Application.CutCopyMode = False

If Range("B2").Text = "EUR" Then
Range("B4:B114").Select
Selection.NumberFormat = "[$ぎ-1809]#,##0.00"
Range("A1").Select
End If

If Range("B2").Text = "USD" Then
Range("B4:B114").Select
Selection.NumberFormat = "[$$-409]#,##0.00"
Range("A1").Select
End If

If Range("B2").Text = "AUD" Then
Range("B4:B114").Select
Selection.NumberFormat = "[$AUD] #,##0.00"
Range("A1").Select
End If



Application.Run "'Price Quote3.xls'! delete_zero"

'Application.Dialogs(xlDialogFormatNumber).Show

Range("B1").Select
Selection.ClearContents


'Do
SaveAsFilename = Application.GetSaveAsFilename _
(fileFilter:="Excel Files (*.xls), *.xls")
'Loop Until SaveAsFilename < False

If SaveAsFilename = False Then
MsgBox "Ok, try later" 'user hit cancel
ActiveWindow.Close savechanges:=False
Exit Sub
End If



CopyToWb.SaveAs Filename:=SaveAsFilename
End If

CopyToWb.Close 'Remove this line if the new workbook shall remain open
'End If
'End If
End Sub

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function



Please can you advise/help me.

Thank you

Winnie



 
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
Colorizing countries Babymech Excel Discussion (Misc queries) 0 June 5th 09 11:13 PM
Using Excel in different countries Giri Excel Worksheet Functions 3 November 19th 05 01:31 PM
world countries zaifi Excel Discussion (Misc queries) 1 October 12th 05 09:17 AM
VBA in other countries uecem[_2_] Excel Programming 0 October 11th 04 08:48 AM
Calculations in different countries No Name Excel Programming 2 June 3rd 04 08:29 AM


All times are GMT +1. The time now is 09:23 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"