Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA Macro Assistance (I am desperate)


Please help

Dear all

I am very new to VBA and I am currently pulling my hair out as I no
longer know what to do with the program that I have written. I would
be eternally grateful to anyone who can show me the light. I have
written a procedure which should look at the only worksheet in my
workbook, and then use the values in column A, to open a designated
account (Excel workbook) then using the values in columns B,C,D update
said worksheet and then move to the next account in column A (The
values in all the columns are different). My problem is that my code
select the different accounts in column and opens them with no
problems, but the values for the data that is posted on all account but
are those from columns B,C,D in row 2 ie the first line and not those
representing the account.

If any of the above is unclear or I can provide any additional
information to help you to assist me please let me know.

My Code is below and I look forward to hearing from you

Kindest Regards

Andrew


Code:
--------------------
Sub withdrawal()
'Declarations
Dim objwb As Workbook
Dim objws As Worksheet
Dim findwhat As Range
Dim rcells As Range
Dim foundcell As Range
Dim foundrow As Integer
Dim rngcashrow As Range
Dim strmfolder As String
Dim strsfolder As String
Dim strmfile As String
Dim straccount As String
Dim strpep As String
Dim strwith As String
Dim curcashval As Currency
Set objwb = Workbooks.Open(Filename:="AndrewN:Users:Reyker:Doc uments:Valuations:PEP dBase", _
ReadOnly:=True)
Set objws = objwb.Worksheets(1)
ActiveWindow.Visible = False
'Userinput
Set findwhat = Sheets(1).Range("a2", Sheets(1).Range("a65536").End(xlUp))
For Each rcells In findwhat
'If findwhat = "" Then End
'Nominal Search Coding
If IsNumeric(rcells) Then
rcells = Left(rcells, 5)
Set foundcell = objws.Columns(1).Find(what:=rcells, after:=objws.Cells(1, 1), _
LookIn:=xlFormulas, lookat:=xlWhole, _
searchorder:=xlByColumns, searchdirection:=xlNext, MatchCase:=False)
Else
'PEPno Search Coding
rcells = Left(rcells, 4)
'findwhat = Left(findwhat, 4)
Set foundcell = objws.Columns(3).Find(what:=rcells, after:=objws.Cells(1, 3), _
LookIn:=xlValues, lookat:=xlWhole, _
searchorder:=xlByColumns, searchdirection:=xlNext, MatchCase:=False)
End If
If foundcell Is Nothing Then
MsgBox ("could not find " & findwhat)
Else
foundrow = foundcell.Row
straccount = objws.Cells(foundrow, 1).Value
strmfolder = "AndrewN:Users:Reyker:Documents:Valuations:"
strsfolder = Application.WorksheetFunction.Floor(straccount, 100) & "s:"
strmfile = strmfolder & strsfolder & straccount
If Dir(strmfile) < "" Then
strmfolder = "AndrewN:Users:Reyker:Documents:Valuations:"
strsfolder = Application.WorksheetFunction.Floor(straccount, 100) & "s:"
strmfile = strmfolder & strsfolder & straccount
Workbooks.Open Filename:=strmfile, ReadOnly:=False
End If
End If
strpep = Worksheets("Template").Range("b2").Value
strwith = Worksheets("Template").Range("c2").Value
curcashval = Worksheets("Template").Range("d2").Value
'If strpep = "" Then End
'If strwith = "" Then End
On Error Resume Next
Set rngcashrow = Range("cashBal").End(xlUp).Offset(-1, 0)
On Error Goto 0
If Not rngcashrow Is Nothing Then
rngcashrow.EntireRow.Insert
rngcashrow.Offset(0, -6).Range("b1") = strpep & " withdrawal - " & strwith
rngcashrow.Offset(0, -1).Range("b1") = curcashval
ActiveWorkbook.Close savechanges:=True
End If
Next
'Close PEP dBase
Workbooks("PEP dBase").Close savechanges:=False
end sub
--------------------


--
adncmm1980
------------------------------------------------------------------------
adncmm1980's Profile: http://www.excelforum.com/member.php...o&userid=14965
View this thread: http://www.excelforum.com/showthread...hreadid=265919

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA Macro Assistance (I am desperate)

That is because you specify to get the data from the

strpep = Worksheets("Template").Range("b2").Value
strwith = Worksheets("Template").Range("c2").Value
curcashval = Worksheets("Template").Range("d2").Value

You would need to adjust those settings to refer to the proper row.

--
Regards,
Tom Ogilvy


"adncmm1980" wrote in message
...

Please help

Dear all

I am very new to VBA and I am currently pulling my hair out as I no
longer know what to do with the program that I have written. I would
be eternally grateful to anyone who can show me the light. I have
written a procedure which should look at the only worksheet in my
workbook, and then use the values in column A, to open a designated
account (Excel workbook) then using the values in columns B,C,D update
said worksheet and then move to the next account in column A (The
values in all the columns are different). My problem is that my code
select the different accounts in column and opens them with no
problems, but the values for the data that is posted on all account but
are those from columns B,C,D in row 2 ie the first line and not those
representing the account.

If any of the above is unclear or I can provide any additional
information to help you to assist me please let me know.

My Code is below and I look forward to hearing from you

Kindest Regards

Andrew


Code:
--------------------
Sub withdrawal()
'Declarations
Dim objwb As Workbook
Dim objws As Worksheet
Dim findwhat As Range
Dim rcells As Range
Dim foundcell As Range
Dim foundrow As Integer
Dim rngcashrow As Range
Dim strmfolder As String
Dim strsfolder As String
Dim strmfile As String
Dim straccount As String
Dim strpep As String
Dim strwith As String
Dim curcashval As Currency
Set objwb =

Workbooks.Open(Filename:="AndrewN:Users:Reyker:Doc uments:Valuations:PEP
dBase", _
ReadOnly:=True)
Set objws = objwb.Worksheets(1)
ActiveWindow.Visible = False
'Userinput
Set findwhat = Sheets(1).Range("a2",

Sheets(1).Range("a65536").End(xlUp))
For Each rcells In findwhat
'If findwhat = "" Then End
'Nominal Search Coding
If IsNumeric(rcells) Then
rcells = Left(rcells, 5)
Set foundcell = objws.Columns(1).Find(what:=rcells,

after:=objws.Cells(1, 1), _
LookIn:=xlFormulas, lookat:=xlWhole, _
searchorder:=xlByColumns, searchdirection:=xlNext, MatchCase:=False)
Else
'PEPno Search Coding
rcells = Left(rcells, 4)
'findwhat = Left(findwhat, 4)
Set foundcell = objws.Columns(3).Find(what:=rcells,

after:=objws.Cells(1, 3), _
LookIn:=xlValues, lookat:=xlWhole, _
searchorder:=xlByColumns, searchdirection:=xlNext, MatchCase:=False)
End If
If foundcell Is Nothing Then
MsgBox ("could not find " & findwhat)
Else
foundrow = foundcell.Row
straccount = objws.Cells(foundrow, 1).Value
strmfolder = "AndrewN:Users:Reyker:Documents:Valuations:"
strsfolder = Application.WorksheetFunction.Floor(straccount, 100) & "s:"
strmfile = strmfolder & strsfolder & straccount
If Dir(strmfile) < "" Then
strmfolder = "AndrewN:Users:Reyker:Documents:Valuations:"
strsfolder = Application.WorksheetFunction.Floor(straccount, 100) & "s:"
strmfile = strmfolder & strsfolder & straccount
Workbooks.Open Filename:=strmfile, ReadOnly:=False
End If
End If
strpep = Worksheets("Template").Range("b2").Value
strwith = Worksheets("Template").Range("c2").Value
curcashval = Worksheets("Template").Range("d2").Value
'If strpep = "" Then End
'If strwith = "" Then End
On Error Resume Next
Set rngcashrow = Range("cashBal").End(xlUp).Offset(-1, 0)
On Error Goto 0
If Not rngcashrow Is Nothing Then
rngcashrow.EntireRow.Insert
rngcashrow.Offset(0, -6).Range("b1") = strpep & " withdrawal - " &

strwith
rngcashrow.Offset(0, -1).Range("b1") = curcashval
ActiveWorkbook.Close savechanges:=True
End If
Next
'Close PEP dBase
Workbooks("PEP dBase").Close savechanges:=False
end sub
--------------------


--
adncmm1980
------------------------------------------------------------------------
adncmm1980's Profile:

http://www.excelforum.com/member.php...o&userid=14965
View this thread: http://www.excelforum.com/showthread...hreadid=265919



  #3   Report Post  
Posted to microsoft.public.excel.programming
N10 N10 is offline
external usenet poster
 
Posts: 141
Default VBA Macro Assistance (I am desperate)

HI for a start you have the following code lines selected as non
operational is this correct

'If findwhat = "" Then End
'findwhat = Left(findwhat, 4)
'If strpep = "" Then End
'If strwith = "" Then End

BEST N10

"adncmm1980" wrote in message
...

Please help

Dear all

I am very new to VBA and I am currently pulling my hair out as I no
longer know what to do with the program that I have written. I would
be eternally grateful to anyone who can show me the light. I have
written a procedure which should look at the only worksheet in my
workbook, and then use the values in column A, to open a designated
account (Excel workbook) then using the values in columns B,C,D update
said worksheet and then move to the next account in column A (The
values in all the columns are different). My problem is that my code
select the different accounts in column and opens them with no
problems, but the values for the data that is posted on all account but
are those from columns B,C,D in row 2 ie the first line and not those
representing the account.

If any of the above is unclear or I can provide any additional
information to help you to assist me please let me know.

My Code is below and I look forward to hearing from you

Kindest Regards

Andrew


Code:
--------------------
Sub withdrawal()
'Declarations
Dim objwb As Workbook
Dim objws As Worksheet
Dim findwhat As Range
Dim rcells As Range
Dim foundcell As Range
Dim foundrow As Integer
Dim rngcashrow As Range
Dim strmfolder As String
Dim strsfolder As String
Dim strmfile As String
Dim straccount As String
Dim strpep As String
Dim strwith As String
Dim curcashval As Currency
Set objwb =
Workbooks.Open(Filename:="AndrewN:Users:Reyker:Doc uments:Valuations:PEP
dBase", _
ReadOnly:=True)
Set objws = objwb.Worksheets(1)
ActiveWindow.Visible = False
'Userinput
Set findwhat = Sheets(1).Range("a2", Sheets(1).Range("a65536").End(xlUp))
For Each rcells In findwhat
'If findwhat = "" Then End
'Nominal Search Coding
If IsNumeric(rcells) Then
rcells = Left(rcells, 5)
Set foundcell = objws.Columns(1).Find(what:=rcells, after:=objws.Cells(1,
1), _
LookIn:=xlFormulas, lookat:=xlWhole, _
searchorder:=xlByColumns, searchdirection:=xlNext, MatchCase:=False)
Else
'PEPno Search Coding
rcells = Left(rcells, 4)
'findwhat = Left(findwhat, 4)
Set foundcell = objws.Columns(3).Find(what:=rcells, after:=objws.Cells(1,
3), _
LookIn:=xlValues, lookat:=xlWhole, _
searchorder:=xlByColumns, searchdirection:=xlNext, MatchCase:=False)
End If
If foundcell Is Nothing Then
MsgBox ("could not find " & findwhat)
Else
foundrow = foundcell.Row
straccount = objws.Cells(foundrow, 1).Value
strmfolder = "AndrewN:Users:Reyker:Documents:Valuations:"
strsfolder = Application.WorksheetFunction.Floor(straccount, 100) & "s:"
strmfile = strmfolder & strsfolder & straccount
If Dir(strmfile) < "" Then
strmfolder = "AndrewN:Users:Reyker:Documents:Valuations:"
strsfolder = Application.WorksheetFunction.Floor(straccount, 100) & "s:"
strmfile = strmfolder & strsfolder & straccount
Workbooks.Open Filename:=strmfile, ReadOnly:=False
End If
End If
strpep = Worksheets("Template").Range("b2").Value
strwith = Worksheets("Template").Range("c2").Value
curcashval = Worksheets("Template").Range("d2").Value
'If strpep = "" Then End
'If strwith = "" Then End
On Error Resume Next
Set rngcashrow = Range("cashBal").End(xlUp).Offset(-1, 0)
On Error Goto 0
If Not rngcashrow Is Nothing Then
rngcashrow.EntireRow.Insert
rngcashrow.Offset(0, -6).Range("b1") = strpep & " withdrawal - " &
strwith
rngcashrow.Offset(0, -1).Range("b1") = curcashval
ActiveWorkbook.Close savechanges:=True
End If
Next
'Close PEP dBase
Workbooks("PEP dBase").Close savechanges:=False
end sub
--------------------


--
adncmm1980
------------------------------------------------------------------------
adncmm1980's Profile:
http://www.excelforum.com/member.php...o&userid=14965
View this thread: http://www.excelforum.com/showthread...hreadid=265919



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.772 / Virus Database: 519 - Release Date: 01/10/2004


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
MACRO assistance MrDave Excel Discussion (Misc queries) 1 August 12th 09 01:10 PM
Macro assistance Rover Excel Worksheet Functions 11 March 17th 09 04:30 PM
Need assistance with printing macro Greegan Excel Worksheet Functions 0 September 7th 05 05:29 PM
Macro assistance (might be tricky) Sean[_7_] Excel Programming 1 May 21st 04 04:47 PM
Macro assistance (might be tricky) Sean[_7_] Excel Programming 0 May 21st 04 04:40 PM


All times are GMT +1. The time now is 04:50 AM.

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"