Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Repeating code

Hi,

Below is part of a code I have which pastes data repetitively down the sheet
for me.

Can anyone advise me how I could loop this or repeat it without having to
copy out this code for each department.

Also where it has Replacement "Other" I would like to put in a text box in
which the user can Identify the name of the department that is to be pasted
in.

Cheers Sue

Range("paste3").Select
Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Select
Sheets("Lookup").Select
Application.Goto Reference:="Item_Nos1"
Selection.Copy
Sheets("B V G").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveWorkbook.Names.Add Name:="paste4", RefersToR1C1:= _
"=OFFSET('B V G'!R1C1,'Lookup'!R4C5,0,'Lookup'! R1C6,3)"
Range("paste4").Offset(0, 1).Select
Selection.Replace What:="", Replacement:="Other", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Repeating code

Does the choice of department also affect the data you are looking up and
pasting? Without knowing more I can only give an outline of a solution, but
you could create a loop like this:

Dim DeptChoice as String

DeptChoice = InputBox("Enter the Department (enter 'done' when
finished):","SELECT DEPARTMENT")
While Not UCase(DeptChoice) = "DONE"
' you would want code here to check for valid input...
' Then put your code from below here to look up and paste your data
DeptChoice = InputBox("Department (enter 'done' when finished):","SELECT
DEPARTMENT")
Wend

HTH!

"SiouxieQ" wrote:

Hi,

Below is part of a code I have which pastes data repetitively down the sheet
for me.

Can anyone advise me how I could loop this or repeat it without having to
copy out this code for each department.

Also where it has Replacement "Other" I would like to put in a text box in
which the user can Identify the name of the department that is to be pasted
in.

Cheers Sue

Range("paste3").Select
Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Select
Sheets("Lookup").Select
Application.Goto Reference:="Item_Nos1"
Selection.Copy
Sheets("B V G").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveWorkbook.Names.Add Name:="paste4", RefersToR1C1:= _
"=OFFSET('B V G'!R1C1,'Lookup'!R4C5,0,'Lookup'! R1C6,3)"
Range("paste4").Offset(0, 1).Select
Selection.Replace What:="", Replacement:="Other", LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False

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
repeating code in visual basic tobypitblado Excel Discussion (Misc queries) 4 September 17th 08 11:55 AM
Repeating Above Value Roger J Michaud Excel Worksheet Functions 3 December 13th 06 02:37 PM
How: Functions repeating... DanStephens Excel Worksheet Functions 4 May 16th 05 09:47 PM
Repeating Lynn Excel Worksheet Functions 2 January 7th 05 04:25 PM
MSG Box Repeating Dale Cox Excel Programming 2 September 12th 03 03:48 PM


All times are GMT +1. The time now is 11:45 AM.

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

About Us

"It's about Microsoft Excel"