W
winnie123
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").PasteSpecial _
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
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").PasteSpecial _
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