Loop That Grabs The Cell And Prints Into Columns On The Spreadsheet

Dec 20, 2009

how to create a loop that grabs the ( t'th ) cell and prints into columns on the spreadsheet adjacently that cell and the ones before it (total = t) and repeats it consecutively until there are no more cells to transcribe into columns. For example - I have n=100 cells in a column that need to be placed into n-t columns (where t = 5 for example).

See image below for clarification, code to follow:

As you can see I need it to fill out in the yellow highlighted cells the rest of that pattern. Right now it only does it for one column, but every time I try to get it to do the rest of the columns, it prints the same first column over and over again (I'm having some severe mental block with implementing the correct loop code).

For clarification also, the user selects the t'th cell and it prints that cell and the previous (3 in this case)... and then it shifts down one cell and prints those 4 cells into the next column - which is what I want it to do.

Sub populate_range()
Application.ScreenUpdating = False
Dim rowoffset As Integer
Dim offsetnumber As Integer
rowoffset = Range("F2")
offsetnumber = Range("F2")
Range("d5:iv5").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Sheet1.Select
Range("b4").Select
ActiveCell.Offset([offsetnumber], 0).Select
Range(ActiveCell, ActiveCell.Offset(-([offsetnumber] - 1), 0)).Select
Selection.Copy............................

View 9 Replies


ADVERTISEMENT

Hide Columns In The Master Files Or The Summary Prints

Jun 27, 2007

I have written quite and extensive macro that takes data from many Excel files and creates a summary of them. The problem is that there needs to be no hidden columns in the master files or the summary prints misinformation. I am looking for a way to keep people from hiding any columns (and rows if possible) unless they have a password. The problem is that many people have to get into the masters to update data, so I can't just put a password on the files and be done with it.

View 3 Replies View Related

Code Prints To PDF But Can It Do So For All 3 Prints?

Feb 19, 2013

The code bellow allows for me have the current sheet saved "printed" to a pdf file with name taken from a cell value.

After that it also prints 3 hard copies with a cell value being changed for each print.

Can I have this but on the pdf code so that the 3 pages are also saved "printed" to pdf?

Code:
'Selects doPDF to genarate PDF file of invoice and names it accordingly to cell L17 which is the invoice number. Application.ActivePrinter = "doPDF v7 on DOP7:"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"E:LusaGenerated InvoicesINV" & Range("L17").Text & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas _
:=False, OpenAfterPublish:=False

[Code] .......

View 1 Replies View Related

Query Grabs The Column Name And Then The Value

Sep 25, 2009

1. When I query it grabs the column name and then the value I am looking for, how do I just grab the value?

2. How can I have the query return the results in the order that they are obtained? For example, lets say I query 3 data points. The first is 1, second is 2, and 3. But when they are put on the excel SS they are in the order 3, 2, 1.

3. In addition to the table I am grabbing below, I have a second table I want to query. The table name is two words, and last time I tried to query it, it did not work.

Sub proSQLQuery1()
Dim varConnection
Dim varSQL

For i = 0 To 1

varConnection = "ODBC; DSN=MS Access Database;DBQ=C:Documents and SettingskbreslinDesktopLydia.mdb; Driver={Driver do Microsoft Access (*.mdb)}"
varSQL = "SELECT VitalStats.birth_date FROM VitalStats WHERE VitalStats.Cases_ID='" & Cells(1 + i, 1).Value & "'"

With ActiveSheet.QueryTables.Add(varConnection, Worksheets("Temp Hold").Cells(2, 4))

.CommandText = varSQL
.Refresh BackgroundQuery:=False

End With
Next i
End Sub

View 9 Replies View Related

Cell Text Prints, But Isn't Seen On Screen

May 2, 2007

For example, a cell on the screen is blank. When the page is printed, the "blank cell" has printed text.

I checked "format cells" and it shows word wrap, merge cells, and left to right.

I was told to "un-merge" the cells. I did that and I still have the problem.

The color on all the cells is OK at a blue shade. When I look at print preview the cells are blank, but when the sheet is printed, the text shows.

Also, it looks like there are 2-3 cells inside the main cell.

I hope I have explained this properly, it is not easy to use the correct language to describe since I am not very good at using Excel.

View 7 Replies View Related

When User Enters Data Into One Cell - Selected Text Prints In Another Cell

Jun 20, 2014

I am trying to do is to make it so that users can enter data into my form (I have managed to create the form and am working on trying to figure out how to get the info entered into the form to appear in my worksheet) and then the data will cause the information to, basically, compile sentences that I want to appear in one of three cells at the bottom of the worksheet.

Essentially, at this point in time, the end goal is to make 3 cells that contain text. Eventually, this text will be indexed elsewhere, but that is for the next person to deal with. I am creating a prototype that I want to present as a process improvement.

So, when the user selects 3 in cell D7 I want the text "Customer purchased 3 Widgets at $20 each." to print in cell 82B.
I also want the user to be able to copy and paste some customer records from another program directly into a cell in the form that will just print (unchanged) into one of these boxes, too.

Lastly, I want the user to be able to select checkboxes that will, when selected, print a comment that will print in two of these boxes. For example, if the user selects yes for cell D26 then I want the text "Customer not eligible for free shipping" to appear in both cells C82 and D82.

View 5 Replies View Related

Loop Is Supposed To Stop When The Cell That Is 4 Columns To The Left

Aug 29, 2008

The loop is supposed to stop when the cell that is 4 columns to the left, in the workbook named "Complete DSS", changes numbers.

/ This is the cell ref. / This is the original
Do While ActiveCell.Offset(0, -4) = ThisTape

The number will stay the same for a while until it changes tapes, then it Should stop when they are no longer equal.

It used to work, but maybe some recent changes have messed up the function.

Sub Compare_printout_2_WDMS()
Application.ScreenUpdating = False
Dim ray, sht As Worksheet, Exist As Boolean
Dim BookA
Dim I As Long
I = Worksheets.Count

AreaNum = InputBox("¿Que es el Area?")
ThisTape = Range("C8").Value
ActiveWorkbook.SaveAs Filename:="C:Documents and Settingssmith27DesktopArea 319 printoutsArea " & AreaNum & " " & ThisTape & ".xls"

Columns("A:A").insert
LR = ActiveSheet.Range("B65536").End(xlUp).Row..........................

View 9 Replies View Related

Loop To Compare Cell In Sheet2 To 2 Columns In Sheet 1

Feb 19, 2010

I need a macro that will look - this is hard to explain so will prob do wee diagram too but basically the macro nees to start looking at sheet2 A5 (the numbers start at A5 before that is text) see if it is greater than Sheet1 ColumnA & Less than Sheet1 columnB if the number is then I need Sheet2 ColumnD inserted into sheet 1 ColumnG. There is the text END on all columns on both sheets for the loop, the reason for the loop of course is there could be 100 lines in sheet2 ColumnA & I must look at all lines in sheet1 to see if it is greater than columnA and Less than ColumnB and if it is populate Column G.

Sheet1
Column A ColumnB ColumnG
Row 11 4000 4999
Row 12 5000 6099
Row 13 6100 7400
ETC
END END
Sheet2

ColumnA ColumnD
Row5 5130 134.58
Row6 6900 6400.00
ETC
END END

After the macro the result would be
Sheet1
Column A ColumnB ColumnG
Row 11 4000 4999
Row 12 5000 6099 134.58
Row 13 6100 7400 6400.00
END END END
Sheet2

ColumnA ColumnD
Row5 5130 134.58
Row6 6900 6400.00
END END

View 9 Replies View Related

Loop To Open Spreadsheet With Varying Name

Mar 24, 2009

I'm especially having trouble with loops. I'm a little dense in that department. Here is what I am trying to do. I open 3 spreadsheets. I want to consolidate them into one of the spreadsheets. The first obstacle I face is that one of the spreadsheets has a name which varies. It is always called either "PLR.xls" or "PendingLoans.xls". Also, it will have a number at the end depending on how many excel books have been opened so far in the day, i.e. "PLR (2).xls" or "PLR (5).xls". At this point, all I want to do is be able to select this file consistently. I currently have something like this (excuse my syntax - its saved at work and like I said, I'm still learning VBA).

View 4 Replies View Related

Loop Through A Spreadsheet Insert Into Another Wb Then Email

May 5, 2006

I am trying to create a macro that loops through a spreadsheet, copies data over to another workbook then emails the new document.

I have taken this code from an old macro that I found but cant seem to get it to work.
This is the code

Sub EmailAssessments()

Dim strTempName As String
Dim strForename As String
Dim strSurname As String
Dim strBookingNumber As String
Dim strReportingTo As String
Dim strBookingGivenBy As String
Dim strJobTitle As String
Dim dtmStartDate As Date
Dim strEndDate As String ''Need to use a string as there maybe no end date
Dim strDepartment As String
Dim strTierName As String
Dim r1 As Range ''For loop
Dim intNumberOfRows As Integer ''Count how many rows.........

View 9 Replies View Related

Auto Copying Text (Not Data) From Cell In One Spreadsheet To Another Spreadsheet Cell?

Nov 4, 2012

I wish to Automatically copy the TEXT that is written from Spreadsheet 1 cells D5 to F5 to Spreadsheet 2 cells F5 to J5 .... a similar range of cells.

Is there a formula I can use or do I need to venture into the programming side of things.

View 7 Replies View Related

Getting 15 Columns In Spreadsheet To Sort On One Columns As It Alphabetizes

Jun 10, 2014

Have a spreadsheet with 15 columns. In one of the columns is the name of the company and that column is not in alphabetical order. The city, state, zip code, business type and all the other pertinent data about that company is in the same row as the name of the company. My intent would be to put the company names in alphabetical order and keep all the company information in the same row as the company name.

View 1 Replies View Related

How To Change File After It Prints

Mar 26, 2014

is there a function to change the file after it prints?

here is my issue, im printing out P.O.'s at work (purchase orders) and i have to put the P.O. number in manually. so i put in say 1601 then i arrow down till i hit the second p.o. number box (2 p.o.'s per page) and then enter 1602 then hit control + P to print then click back at the top and repeat but changing the number to 2 more than the number previously in the box.

is there some what to do this automatically so i dont have to do it my self?

View 3 Replies View Related

Detect If User Prints

Dec 12, 2006

Is there anyway to detect if the user has just printed. I have code which transfer data from the sheet to an access file when the user prints using the button I placed on the sheet, unfortunately some users are using the print button on the toolbar.

View 9 Replies View Related

Macro Prints In Landscape Not Portrait

Dec 18, 2008

I am using the following code written by a former employee to set a print area for 3 different ranges in my workbook. For some reason the pages are coming out in a landscape format. How do I get the macro to print in portrait?

View 2 Replies View Related

Multiple Prints Form One Sheet

May 11, 2012

I work in a hospital laboratory and we are performing an antibiotic study. I have a work book consisting of 2 sheets

1 sheet is a list 7 antibiotics in a column for a1 to a8
2 sheet is a blank results sheet

What I want to do is print out the blank result sheet once for every antibiotic on sheet 1 with the name of the antibiotic in sheet 2 pos "a,1"

I have copied the blank 7 times and linked to the antibiotic list but this seems very untidy.

Is there a way to print out 7 identical sheet2's differing only by reference to sheet 1 a1 to a8.

View 1 Replies View Related

File Location For Screen Prints

Jun 30, 2006

I am trying to write a macro which does a screen print of a couple of sheets in a spreadsheet. I created the macro using the recorder function and then trimmed it down a bit. However, when I run the macro it pops up with the box asking for a file location, and this is not something that the recoder function seems to write into the macro. I am not sure how to have the macro autofil the file location for the screen print. Is there anyone out there who can give me a hand with this? Thanks. The code for the macro is below...

Sub ScreenPrint()
Sheets( Array("Sheet1", "Sheet2", "Sheet3")).Select
Application.ActivePrinter = "Microsoft Office Document Image Writer on Ne00:"
Selection.PrintOut Copies:=1, ActivePrinter:= _
"Microsoft Office Document Image Writer on Ne00:", Collate:=True
Sheets("Sheet1").Select
End Sub

View 3 Replies View Related

Hp Printer Prints Blank Pages

Jun 14, 2007

When printing an Excel workbook/Worksheet that has been emailed via Lotus notes 7.02 the print job is all blank pages - PrintPreview is normal and correct - Page Breaks are set correctly - The correct number of pages are printed but, ALL Pages are blank. The printer is an HP 6310 All-in-One connected locally via USB. If Printed to Adobe, ALL pages are correct and can be printed on the HP 6310. If another printer is selected (ie: Any Network Printer) the results are the same. This occurrs only on certain spreadsheats received from only a few users.

View 3 Replies View Related

Excel 2003 :: Only Partial Page Prints?

Jul 27, 2008

Using Excel 2003 I have had this problem ocassionally, and I can't figure out what causes it or how to fix it. In a workbook of several excel worksheets I will ask to print a mulitple page worksheet and only 2/3 of every page prints. This also happens if I print to an Adobe acrobat file, and typically happens when I am printing to pdf files. The selection is correct; there are no page breaks . . . it is just some sort of glitch. The only way I get rid of it is to close down and reboot .

View 8 Replies View Related

VBA Code - Userform That Prints Data Entered Onto Worksheet

Apr 9, 2012

I am having some difficulties with my VBA code. It is a user form that prints the data entered on to a worksheet. However, I am having some troubles with the calculations I want it do. Here is code...

PHP Code:

Private Sub CommandButtonExit_Click()
Unload Me
End Sub

Private Sub CommandButtonClear_Click()
Dim ctl As Control

[Code] .......

I keep getting a run-time error.

View 6 Replies View Related

Macro Which Cycles Through User Inputted Values And Prints Sheet

Jun 21, 2014

I'm looking to create a macro which displays a user entry box where the user can input a starting number and then input an ending number. The macro will then cycle through that range inputting each value into a specific cell and perform a print function. It will continue doing this until the last number in the range.

E.g.
Min. Number inputted = 1
Max. Number inputted = 80
Macro will not cycle through that range:
Input 1 into Sheet1 Range A1
Print Page
Input 2 into Sheet1 Range A1
Print Page
.....Continue doing this until it reaches 80

View 3 Replies View Related

Shared File Prints Differently For Different Users - Autofit Wrapped Cells

Apr 16, 2014

Here's the details:

Same file shared by many users in the office. File is maybe 2200 rows long and 20 columns wide. Last column is a text field where users can explain variances. Cells in the last column are wrapped and the rows auto-fit on the height. Zoom is set at 100%.

One person opens the file and it looks fine on the screen. Print preview also looks fine. File prints out perfectly.

Another user opens the file and it looks fine on the screen. BUT, print preview shows that the bottom line or lines of text is cut off. File prints exactly like the preview showed with clipped text.

Both users can point the file to the same printer, but that doesn't seem to change anything. Still prints with text clipped for one person and perfectly for another...

View 1 Replies View Related

Loop Through Columns And Row?

Aug 16, 2014

I want to perform double_click event for combobox, but only for cells in certain columns and rows.

this is code :

[Code] ....

I have to loop through columns 6 to 67 with step 1, and rows 19 to 409 with step 5, but don't know how . I attached sample, coloured cells needs that double_click event.

Attached File : Loop_Column_Row.xls

View 12 Replies View Related

Loop To Run Through Columns

Apr 15, 2008

I am having some problems in setting up a macro that is intended to do the following

Run for every cell in a collumn a check if cell =2
If true then B1 is copied to that cell.
If false then nothing

This seems rather simple but the loop should go to collumn B, C, D, E, F,... until the last collumn.

Every time the collumn shfits the cell to be copied also shifts so is B1, C1, D1, E1, F1,...

View 14 Replies View Related

VBA - Loop Through Columns

May 12, 2011

I have a data set that I need to reorganise

Currently the data runs across the columns as:

COL A:C = Descriptions
ROW 1:1 = Week End dates
ROW 2:2 = Week Number
and D3:BC122 = Values
AccData

[code].....

What I need to do is create some VBA that will loop through E:BC moving the data in the column to under the data in Col C each time (and also A:C)

I can create loops that add 1 to row number but am stuck adding 1 to column in VBA.

View 7 Replies View Related

Loop On Two Columns?

Apr 5, 2013

I have two columns of data J2:K1000, I need loop through both columns at the same time and copy the data into cells into E1 and F2, then run through the remainder of the code. The code below I have adapted but cannot get it to work correctly.

HTML Code:

Sub Test()
Dim LastRowColJ, LastRowColK As Long
Sheets("Sheet1").Select
LastRowColJ = Range("J65536").End(xlUp).Row
For Each c In Worksheets("Sheet1").Range("J2:J" & LastRowColJ).Cells
Sheets("Sheet1").Range("E1").Value = c
For Each d In Worksheets("Sheet1").Range("K2:K" & LastRowColJ).Cells

[code]....

View 4 Replies View Related

Loop Columns

Aug 21, 2009

my worksheet has columns e1:il100 populated with data. what i am trying to do, is to insert a column to the right of column 'e', copy the contents of cell 'e1', to rows 3:100. then i want to cut e3:f100, and place it in the next available row in columns b:c, delete columns e:f, and then goto the next populated column, which i believe is now column e, and start over, until all columns have been moved to columns b:c.

View 9 Replies View Related

Loop Through Columns

May 3, 2007

I have a dataset with has 12 columns of data followed by 49 columns of values (one for each product) What I need (to be able to pivot it) is one column of values. I had written a quick for each loop but this doesnt work for colums:

Sub Adjust()
' Find last cell populated by data
Range("A65535").End(xlUp).Select
Last_Cell = ActiveCell.Row
'Rename a column heading
Range("M1").Value = "Partner"
Range("M2:M" & Last_Cell).ClearContents
'Loop through each column and copy data values
For Each Column In Range("N:BJ")
' Find first empty cell
Range("N65535").End(xlUp).Select
Start_Cell = ActiveCell.Row + 1.....................

View 2 Replies View Related

How To Create Loop Through Among Columns

Apr 30, 2012

i would like to create loop throug among columns, is xlup or xldown methods will make sensne ?

View 2 Replies View Related

Loop Through Columns And Sum Them At Bottom

Nov 17, 2008

I've been working on coding a summary sheet that pulls data from
worksheets in the active workbook.

I'm almost done, but am stumped at writing some code that will loop
through the columns that I have copied and total them. I recorded a
macro, but nothing happened when I ran it.

What I have now is this code snippet that I found which works
perfectly when I put my cursor in the active cell.
I am not sure how I should write it into my sub.

code that I found that works:

Set rng1 = ActiveCell.End(xlDown)
Set rng2 = rng1.End(xlUp)(2, 1)
rng1(3, 1).Formula = _
"=Sum(" & Range(rng2, rng1).Address(False, False) & ")"

I tried this:

For Each col In NewSh
ColNum = ColNum + 1
Range(RwNum, ColNum).Select

Set rng1 = ActiveCell.End(xlDown)
Set rng2 = rng1.End(xlUp)(2, 1)
rng1(3, 1).Formula = _
"=Sum(" & Range(rng2, rng1).Address(False, False) & ")"

Next col

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved