Single Cell Copy to Cell Range
If I create a cell value/formula, then copy that cell, select a range of cells, and paste, in Excel it copies the source cell contents to all cells in the range (adjusting relative references in a formula). In Numbers, it copies only to one cell in the range. Having to paste one cell at a time is agonizing, and this operation is something I do all the time in editing an existing spreadsheet.
The only alternative I see is to copy one cell to two, then select a two-cell range to copy and paste etc in geometric progression. Is there something simple I'm missing?
I did a search in the help for "fill" & got this:
Here are ways to autofill table cells:
To paste the content and fill of a cell into adjacent cells, select the cell and then drag the Fill handle in its lower right corner over the cells into which you want to paste. You can drag to the right to add values to adjacent cells in the same row, or you can drag down to add values to adjacent cells in the same column.
Any data, cell format, formula, or fill associated with the selected cell is pasted, but comments aren’t pasted.
If the selected cell contains no data, autofilling clears data from target cells.
You can also add values to cells based on value patterns. For example, if a cell contains a day of the week or a month, you can select the cell and then drag to the right or down to add the next day of the week or month to the adjacent cell.
To create new values based on numeric patterns, select two or more cells before dragging. For example, if two selected cells contain 1 and 2, the values 3 and 4 are added when you drag through the adjacent two cells. And if two selected cells contain 1 and 4, the values 7 and 10 are added when you drag through the adjacent two cells (values are incremented by 3).
This is similar to how I've done fill down or fill right in AppleWorks, so I think the relative references would copy.
Similar Messages
-
How To Load SINGLE CELL Value as Object - In 2D Object Array - InvalidCastException
Setup: ---- VB.net - Visual Studio 2010 - Excel Version 2010 - Option Strict ON
The following WORKS FINE all day long for loading MULTIPLE range values IE: ("F2:F5") or more into a 2D Object Array... No problem... as in the following..
Dim myRangeTwo As Range = ws.Range("F2:F5") ' MULTIPLE CELL RANGE
Dim arr2(,) As Object = CType(myRangeTwo.Value(XlRangeValueDataType.xlRangeValueDefault), Object(,))
The ws.range("F2:F5") values are stuffed into the myRangeTwo range variable as 2D Objects and then those are easily stuffed into the 2D object array...
But this does not work for a SINGLE cell range...
Dim myRangeTwo As Range = ws.Range("F2:F2") ' SINGLE CELL RANGE F2 ONLY
Dim arr2(,) As Object = CType(myRangeTwo.Value(XlRangeValueDataType.xlRangeValueDefault), Object(,))
This triggers an Invalid Cast Exception error on trying to load into the arr2(,).. because the ws.range("F2:F2") is stuffed into the myRangeTwo variable as a "string"
not as an object therefore is not possible to stuff it into an Object Array and so correctly causes the Invalid Cast Error...
How do you handle this seemingly ridiculously simple problem ??
thanks... CjHello,
Simply answer, you need to determine if the range is a single cell or multiple cells. So the following is geared for returning a DataTable for a start and end cell addresses that are different, granted there is no check to see if the cells are valid i.e.
end cell is before start cell i.e.
Since B1 and B10 is a valid range we are good but if we pass in F1:F1 or F10:F10 we must make a decision as per the if statement at the start of the function and if I were expecting this to happen I would have another function that returned a single value.
Option Strict On
Option Infer On
Imports Excel = Microsoft.Office.Interop.Excel
Imports Microsoft.Office
Imports System.Runtime.InteropServices
Module ExcelDemoIteratingData_2
Public Sub DemoGettingDates()
Dim dt As DataTable = OpenExcelAndIterate(
IO.Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
"GetDatesFromB.xlsx"),
"Sheet1",
"B1",
"B10")
Dim SomeDate As Date = #12/1/2013#
Dim Results =
From T In dt
Where Not IsDBNull(T.Item("SomeDate")) AndAlso T.Field(Of Date)("SomeDate") = SomeDate
Select T
).ToList
If Results.Count > 0 Then
For Each row As DataRow In Results
Console.WriteLine("Row [{0}] Value [{1}]",
row.Field(Of Integer)("Identifier"),
row.Field(Of Date)("SomeDate").ToShortDateString)
Next
End If
End Sub
Public Function OpenExcelAndIterate(
ByVal FileName As String,
ByVal SheetName As String,
ByVal StartCell As String,
ByVal EndCell As String) As DataTable
If StartCell = EndCell Then
' Decide logically what to do or
' throw an exception
End If
Dim dt As New DataTable
If IO.File.Exists(FileName) Then
Dim Proceed As Boolean = False
Dim xlApp As Excel.Application = Nothing
Dim xlWorkBooks As Excel.Workbooks = Nothing
Dim xlWorkBook As Excel.Workbook = Nothing
Dim xlWorkSheet As Excel.Worksheet = Nothing
Dim xlWorkSheets As Excel.Sheets = Nothing
Dim xlCells As Excel.Range = Nothing
xlApp = New Excel.Application
xlApp.DisplayAlerts = False
xlWorkBooks = xlApp.Workbooks
xlWorkBook = xlWorkBooks.Open(FileName)
xlApp.Visible = False
xlWorkSheets = xlWorkBook.Sheets
' For/Next finds our sheet
For x As Integer = 1 To xlWorkSheets.Count
xlWorkSheet = CType(xlWorkSheets(x), Excel.Worksheet)
If xlWorkSheet.Name = SheetName Then
Proceed = True
Exit For
End If
Runtime.InteropServices.Marshal.FinalReleaseComObject(xlWorkSheet)
xlWorkSheet = Nothing
Next
If Proceed Then
dt.Columns.AddRange(
New DataColumn() _
New DataColumn With {.ColumnName = "Identifier", .DataType = GetType(Int32), .AutoIncrement = True, .AutoIncrementSeed = 1},
New DataColumn With {.ColumnName = "SomeDate", .DataType = GetType(Date)}
Dim xlUsedRange = xlWorkSheet.Range(StartCell, EndCell)
Try
Dim ExcelArray(,) As Object = CType(xlUsedRange.Value(Excel.XlRangeValueDataType.xlRangeValueDefault), Object(,))
If ExcelArray IsNot Nothing Then
' Get bounds of the array.
Dim bound0 As Integer = ExcelArray.GetUpperBound(0)
Dim bound1 As Integer = ExcelArray.GetUpperBound(1)
For j As Integer = 1 To bound0
If (ExcelArray(j, 1) IsNot Nothing) Then
dt.Rows.Add(New Object() {Nothing, ExcelArray(j, 1)})
Else
dt.Rows.Add(New Object() {Nothing, Nothing})
End If
Next
End If
Finally
ReleaseComObject(xlUsedRange)
End Try
Else
MessageBox.Show(SheetName & " not found.")
End If
xlWorkBook.Close()
xlApp.UserControl = True
xlApp.Quit()
ReleaseComObject(xlCells)
ReleaseComObject(xlWorkSheets)
ReleaseComObject(xlWorkSheet)
ReleaseComObject(xlWorkBook)
ReleaseComObject(xlWorkBooks)
ReleaseComObject(xlApp)
Else
MessageBox.Show("'" & FileName & "' not located. Try one of the write examples first.")
End If
Return dt
End Function
Private Sub ReleaseComObject(ByVal sender As Object)
Try
If sender IsNot Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(sender)
sender = Nothing
End If
Catch ex As Exception
sender = Nothing
End Try
End Sub
End Module
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. -
Copy and Paste Multiple lines into a single cell
Folks:
I need to copy some plain text data into a single cell that has been merged with other cells to provider a larger unit; however, every time I copy and paste my data it gives me an error. In addition, if I paste the data into a single cell, the next line
of data inserts into the next row.
I understand that Alt+enter is a quick way to do what I want, but I already have the data typed out, and I do not want to type the data again.
Example: (If possible I want in one single cell)
Disks=32
Total space=1.74TB
Used space=1.20TB
Free space=0.54TB
Thank you!!!Is there any way to do this but keep the source formatting? I don't see any "Paste Special" options when you do it this way.
That is not possible - when you copy/paste this way, you only copy the plain text, not the formatting. You'll have to apply formatting to the cell with pasted lines from scratch.
Regards, Hans Vogelaar (http://www.eileenslounge.com) -
How do I insert or delete a single cell?
For example, I want two columns of text. aligned horizontally, and, separated by a blank column.
The two text lists have been created in other applications.
So I copy list1, and paste it in cell C7.
Then I copy list2, and paste it cell G6.
oops. Now the lists are not aligned horizontally.
The easiest way to align the lists is by either delete a single cell in column C or insert a single cell in column G.
But I can't find the option to add/delete single cells.
Does that option exist in Numbers? If so, how/where?
Thanks,
AJAJ,
My first thought on reading your post was: why are you using a single table for two side-by-side lists? If you had used two single-column tables you could use Delete Row or Insert Row to do what you want.
pw and John both gave you perfectly good solutions, and I just wanted to add my two cents worth. I don't see much value in the Add/Delete Cell feature that you are looking for. The action never ends there because there's always a followup question as to what you want to do with the data to the right of and below the affected cell. So, it hasn't saved you any real time.
Numbers has a very handy and secure method for moving a range of data. Highlight the range that you want to move. Then, Edit > Mark for Move. Now, click in the new starting location and Edit > Move.
There you go; several ways to recover from the inevitable oops. Depending on how soon you discover your mistake, Command-Z is probably the easiest fix.
Jerry -
How do I use variables to define a cell range?
I have a series of data elements that are organized by date. I need to find a list of dates when specific events have occurred (each event is marked by a flag value of 1). I'm using VLOOKUP to find the first date when the event occurs. For the next date I need to adjust the cell range I'm searching so that it won't pick up the first occurence of the flag value (1).
Example:
1st query =VLOOKUP(1,G3..G223,51,0)
The first query returns a date that is in row 12. I now need to make the second query look for rows 13 through 223.
Overall I need to create over 500 such queries (50 columns of data and 10 events in each row), so typing in each query individually is not an appealing option.
Thanks!Hi Dad,
I'm having some trouble with your description of the data table. If I read it correctly, the cells in column G contain either a 1 or are empty (or contain a zero). If this is correct, and you are using column G to hold the compare range, then, as the VLOOKUP description in AppleWorks Help states, "If the values in the compare range are not in strict ascending or descending order, or the compare range does not contain an inclusive range from the highest to lowest possible value, the results can be unpredictable." It's very difficult to place the values 0 and 1 into 221 individual cells in "strict ascending order."
VLOOKUP(v,cr,os,m) looks for a specific value (v) in a strictly ordered list of values (cr), and when that value is found*, returns the value in the cell that is in the same row and offset a specific number of columns (os) to the right.
*The method of comparison (m) determines whether an exact match is necessary or if the comparison can be <=v or >=v.
•From the Compare range in your formula, your table has 221 rows (3 through 223). My assumption is that you are recording data for 221 specific dates.
•From the offset value in the formula (51) the table has 52 columns—a compare range column, a result column, and 50 others between them.
•From your formula, it appears that only one column of the chart is being used as a compare range for a particular search (event?).
•You state you have 50 columns of data and that there are 10 events in each row (of 52? cells).
From the last statement, I infer that there are 50 distinct possible events (one for each column), and that 10 of these 50 events occur on each date. Is that correct?
If I understand the description, then my impression is that VLOOKUP is not an effective tool for this job.
Instead, I would suggest a larger table and a set of formulas which will construct a list of the dates on which each event occurs. (Note that the maximum length of a formula, and the maximum length of data for a single cell are both 255 characters. This may necessitate some adjustment to the formulas if one event occurs a great number of times.)
The larger table will consist of two (or three) sections:
•a data entry section much like my understanding of your current table. One column will contain a list of dates. Fifty other columns will each represent a single type of event. Each cell in that column will contain a 1 if the event occurred on the date listed in that row, or will be empty if the event did not occur on that date. for illustration purposes, the dates will be listed in F3..F223, and the events in columns G..BD, with the occurence of Event 1 reported in G3..G223.
•A calculated section which copies the contents of the data block, substituting the correct date for each occurrence of a 1 in the data. In this block (BF3..DC223), column BF will list the dates on which event 1 occurred, column DC the dates on which event 50 occurred. Row 2 (or Rows 1 and 2) in this secton will repeat the headers in the data entry section.
Formulas:
BF1: =G1
Fill this formula Down and Right to DC2
BF3: =IF(G3=1,=DATETOTEXT($F3),"")
Fill this formula Down and Right to DC223
Collecting the dates:
Open a new Word Processor document.
For EACH event, switch back to the spreadsheet document, select the full column containing the dates for that event (eg. BF1..BF223 for Event 1) and Copy.
Switch to the word processor document and Paste, then press shift-return twice (This enters a visual separation that will not be removed in the next step.)
Save the (temporary) WP document. You will have to name it the first time. After that, just press command-S. (This gives you a fall back if you make—and notice—an error along the way.
Repeat these three steps until you have transfered all 50 columns of data (including the empty cells in each column) into a single list in the WP document.
Now use Find/Change to remove all of the empty lines in the list.
Press command-F to open the Find/Change dialogue.
Type "\p\p" into Find and "\p" into Change (both without the quotes).
Repeat the next three steps until AppleWorks reports "0" occurences were changed.
Click Change All.
Click OK to acknowledge the warning that this action is irreversible.
Read the number of changes that occurred, then Click OK to close this alert.
You will now have a single column list of each event, followed by the dates on which it occurred. If you want to show this list as a table (in a spreadsheet), Select and copy each section Event and dates it occurred) individually, switch to the spreadsheet, click on the cell where you want that column of dates to begin, and Paste. Repeat.
It may be possible to automate this last part, either through a further section in the spreadsheet, or through the use of an AppleScript to collect and organize the calcualted data.
Regards,
Barry -
I see people from different ages at my work and every month I need to count how many people from each age I've seen that month. How can I do to give the entries to numbers in a single cell and make numbers count them for me? The final result would be a spreadsheet telling there were 8 people from 20 to 39 years old, 14 peolple from 40 to 59 and so on...
jpqcampos wrote:
This appears to be an 'input form' using 'Radio Buttons' to select the category. Neither of these features are supported in Numbers '09.
You can input the data on one table and summarize it on a second table, but the input table will continue to hold data for each event.
And by using the Reorganize button, you can hide all but two rows of that table to approximate the appearance and performance of an input form.
Here are the two tables, Data on the left and Summary on the right. Notes below.
The grey-filled columns in both tables are 'working' columns, and may be hidden (as shown in the image below).
Data table:
D1 contains the word "TRUE" (in capital letters). (This row is always shown.)
D2 is empty, or may contain any value except "TRUE" (This row is always hidden under the Reorganize rule.)The rest of Row 2 of this table requires the data shown: a number outside the range to be counted (999), and two checkboxes, both checked.
D3 (and filled down the rest of column D): =AND(OR(B2,C2),NOT(OR(B3,C3)))
The formula returns TRUE only for the first unused row in the table (ie. the first row for which neither checkbox has been checked)
Summary table:
Column A contains labels for the age ranges to be counted.
Column B contains the same information in the form necessary for the formulas in columns C and D. They need a numeric value, and that value must be the largest acceptable value in the range to be counted.
C2 (and filled right to column D, then both filled down to row 5):
=COUNTIFS(Data :: $A,"<="&$B,Data :: B,TRUE)-SUM(C$1:C1)
Two changes from the previous example:
COUNTIFS is used to separate the Native and Foreign counts as well as the age range to be counted.
The amount subtracted from each result is the SUM of the earlier results, and includes the text value in the first cell of the column (which is interpreted by SUM as a zero).
See note below regarding my earlier formula.
When the greyed columns are hidden and the checkbox in the Reorganize pane is checked, the two tables will appear as shown below:
Close the reorganize pane, and the 'data entry form' is ready to use.
To use, enter the age first, then check one of the boxes.
As soon as one box is checked, the row will be hidden, and the next (unused) row will be shown.
Regards,
Barry
Note regarding formula in my earlier post:
The earlier formula will give erroneous results as it subtracts only the count directly above it from its count of persons in the age range 0-n.
In E2 of that table, replace "-E1" with "-SUM(E1:E$1)
Fill down to E8.
Ignore the instructions (in that post) following "Fill down to E8."
B -
How to find multiple keys in single cell using Numbers?
I'm trying to add functionality to one of my Numbers tables where want to check a single cell for multiple keywords from a list. The hole thing works perfectly fine in Excel but it behaves differently in Numbers.
The formula I am using is:
=IF(ISERROR(LOOKUP(2^15;FIND($E$2:$E$11;A2)));"not found";"found")
The following screenshots show that it correctly finds the keys in the cell when using Excel but not in Numbers. Although, it seems to work if the key is in the same row as the input cell.
Excel table using the formula I posted in the C column:
Numbers table using the formula I posted in the C column:
Would be really happy if somebody knows how I could accomplish that!
Cheers,
MaikIf you are working in Numbers you can do this efficiently with a small AppleScript without going back to Excel or clone. One click and you get the following result:
This script works with Numbers 2.3, which your screenshot suggests you are using. If you are using Numbers 3 it needs a very small adjustment.
This is the script:
--https://discussions.apple.com/thread/6315365?tstart=30
property inputCol : 1 --> col A, as in example
property resultCol : 3 --> col C, as in example
property keysCol : 5 --> col E, as in example
property targDoc : 1 --> 1 is front document; can change to "MyDocName"
property targSheet : 1 --> 1 is first sheet; can change to "MySheetName"
property targTable : 1 --> 1 is first table; can change to "MyTableName"
tell application "Numbers"
set t to document targDoc's sheet targSheet's table targTable
set keysList to t's column keysCol's cells's value
repeat with i from 2 to t's row count -- assumes 1 Header Row
set inputVal to t's row i's cell inputCol's value
if inputVal is not 0 then --skip blank cells; Numbers 2 reads blanks as 0
--check if Input matches a key:
if inputVal is in keysList then
set t's row i's cell resultCol's value to "found"
else
set t's row i's cell resultCol's value to "not found"
end if
--check if Input contains a key:
repeat with aKey in keysList
if inputVal contains aKey then set t's row i's cell resultCol's value to "found"
end repeat
end if
end repeat
end tell
--end of script
To run, copy into AppleScript Editor, change the properties if needed, and click the green triangle 'Run' botton.
SG -
Okay, I can insert a whole row or column, but how do I insert a single cell? Say I need to add a cell at G8, moving the data down one cell. Rather than trying to select 325 cells and move them down.
Simple in Excel, but I'm giving Numbers a reason to not use Excel.
Anyone?I still submit that you haven't "grokked" the Numbers yet. I have used it extensively and have never needed this feature.
Well, I guess it's true I have not "grokked" Numbers yet. And yes, the data was entered inconsistantly, Jax, and that's the problem I'm trying to fix. All of which would be easier if I had a simple Add Single Cell command. Goodness, it's not like I'm asking for the Red Sea to part, just a single column.
I'm dealing with 2 tables, each with 12 categories, 60 entries per category, and I'm trying to compare the two. I sorted each by category and then by entry. Then I copied and pasted the appropriate columns from Table 2 over to Table 1. After moving columns around (which is easier than in Excel, admittedly), I'm going down the columns and looking for discrepancies. Finding one, I need to bump a column down a cell so I can add the missing entry so both columns are exactly the same. There are cells missing in both columns, so I can't assume one is more correct than the other.
So I guess the Martian thing to do (being a stranger in a strange land, i.e., a non-Microsoft spreadsheet), would be create 12 different tables based on twelve different categories. Of course, then I'll need to combine them back together because sometimes I sort by entry, not just category. Effective multiplying my efforts by 12.
Oh, and I was well aware of the demo, thank you very much. I'm a few months passed the 30 day limit before this project came about. I bought the software in an attempt to cut away from Microsoft Office. Surely y'all can understand that. Going cold turkey wasn't such a good idea, I guess. -
Populate multiple rows and columns based off of a single cell
Does anyone know a way to populate multiple rows and columns based off of the input of a single cell. I'm trying to create a workout tracker that auto populates from a master list of workouts. Example, in A2 the user selects the workout from a drop down menu (St1, St2, St3, etc) and the workout is pulled from the master list and is populated into B2:C5.
I'm using =LOOKUP(A2,Master :: A2:A32,Master :: C2:C32) right now, but it's only drawing the top column. I'm looking for an edit for the formula (or completely new formula) that will place the info from the 1st column of the Master table into the 1st column of the Auto Tracker 1 table and then on down until the 4th column.
Here is a screen shot of what I have now:
And an example of what I'd like to accomplish:
Any and all help is appreciated, and please let me know if there is any more info that I can give that'd help out.Hi Mike,
Your screenshots show that you have merged some cells in Column A of both tables. That may be the reason why the LOOKUP function is having trouble working out which range of cells to examine.
Hope this helps.
Regards,
Ian. -
Dynamic Alerts per single cell in a dashboard
Hi,
I am trying to create a dashboard in which the main requirement is to show alerts per cell in a table(either in a spreadsheet table or scorecard component).
I have used the spreadsheet table to display data and used rectangle components on top of each cell of the spreadsheet to display alerts based on dynamic visibility.
This kind of solves the problem of single cell alerts, but here another issue is, if the data for a given selection in the header navigation has only 5 columns as opposed to 10 columns for a different selection, the width of the spreadsheet cell is not dynamically picking up as the user wants the no. of output columns to be evenly distributed in the component than re-sizing the component of the canvas.
I am trying to use Scorecard alerts, but i don't know how to create dynamic range.
Here is the condition of my alerts...
From database per data row, i will have either R or G(the logic is pre-calculated )
If the query retrieves R per row for that fact value, then show that fact value as number and display the alert in RED
Similarly for G, display GREEN color.
Can someone help how to accomplish this?
Thanks,
Medha.Have you mapped the alerter values correctly ? Can you provide a full screenshot of the alerter configuration screen ?
-
Modifying single cell in ALV Grid via OO
Hi All,
Got a problem I hope someone can assist me with. I have a custom program generating an editable ALV grid. The users want to update a single cell in a row with value from a custom drop down. I've got the dropdown working, but I can't work out how to get the value back into the field. My attempts result in a 'GETWA_NOT_ASSIGNED' short dump.
I'm using the CL_GUI_ALV_GRID->get_selected_cells_id method to get the reference for the field to be modified, but I don't know where to go from here.
Any thoughts would be greatly appreciated. Btw, my knowledge of OO is passable, but not great, so any explanations of what the code is doing in a proposed solution would be greatly appreciated.
points will be rewarded.
Cheers,
StephenHello Stephen
Since your dropdown list restrict the already allowed values there should be no special need to validate the selected values.
Simply "grab" the data from the editable ALV into your internal itab in the ABAP report.
I have copied sample report BCALV_EDIT_07 into ZUS_SDN_BCALV_EDIT_07 and modified the report to show how to retrieve the dropdown values (which is simple). Please note that I added the GUI-function 'SAVE' to the GUI-status MAIN100.
* MODULE PAI INPUT *
MODULE pai INPUT.
save_ok = ok_code.
CLEAR ok_code.
"$TMP
g_grid->check_changed_data( ). " retrieve changes from editable grid
CASE save_ok.
WHEN 'EXIT'.
PERFORM exit_program.
"$TMP
WHEN 'SAVE'.
PERFORM save_data.
WHEN OTHERS.
* do nothing
ENDCASE.
ENDMODULE. "pai INPUT
*& Form SAVE_DATA
* text
FORM save_data. "$TMP
* define local data
data: ls_fcat type lvc_s_fcat,
lt_fcat type lvc_t_fcat.
lt_fcat = gt_fieldcat.
ls_fcat-edit = ' '.
modify lt_fcat from ls_fcat
TRANSPORTING edit
where ( edit = 'X' ). " display ALV should be not editable
" Simulate saving of data
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'Display modified list data'
* I_GRID_SETTINGS =
* IS_LAYOUT_LVC =
IT_FIELDCAT_LVC = lt_fcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS_LVC =
* IT_SORT_LVC =
* IT_FILTER_LVC =
* IT_HYPERLINK =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT_LVC =
* IS_REPREP_ID_LVC =
I_SCREEN_START_COLUMN = 5
I_SCREEN_START_LINE = 5
I_SCREEN_END_COLUMN = 120
I_SCREEN_END_LINE = 20
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IT_EXCEPT_QINFO_LVC =
* IR_SALV_FULLSCREEN_ADAPTER =
TABLES
t_outtab = gt_outtab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "SAVE_DATA
And here is the entire coding: In order to find the modified parts of the coding simply search for $TMP.
PROGRAM zus_sdn_bcalv_edit_07.
* Purpose:
* ~~~~~~~~
* This example shows how to define dropdown listboxes for
* particular cells of your output table.
* To check program behavior
* ~~~~~~~~~~~~~~~~~~~~~~~~~
* Conceive that customers are only allowed to smoke in the
* first class. For this reason, if the customer is a smoker
* only the first class (F) can be chosen in column 'CLASS',
* otherwise all classes.
* Essential steps (search for '§')
* ~~~~~~~~~~~~~~~
* 1.Define an extra field in your output table
* 2.Define a dropdown table and pass it to ALV.
* 3.Set your dropdown field editable and assign the fieldname of the
* corresponding additional field to DRDN_FIELD of the fieldcatalog.
* 4.Set the handle of your additional field of your output
* table according to the listbox that shall be displayed.
DATA: ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
gt_fieldcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo,
g_max TYPE i VALUE 100.
*§1.Define an extra field in your output table
* for each column where you want to use drop down listboxes.
* (One additional field refers to cells of one column).
DATA: BEGIN OF gt_outtab OCCURS 0.
INCLUDE STRUCTURE sbook.
DATA: drop_down_handle TYPE int4.
DATA: END OF gt_outtab.
* MAIN *
END-OF-SELECTION.
CALL SCREEN 100.
* MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
IF g_custom_container IS INITIAL.
PERFORM create_and_init_alv CHANGING gt_outtab[]
gt_fieldcat.
ENDIF.
ENDMODULE. "pbo OUTPUT
* MODULE PAI INPUT *
MODULE pai INPUT.
save_ok = ok_code.
CLEAR ok_code.
"$TMP
g_grid->check_changed_data( ). " retrieve changes from editable grid
CASE save_ok.
WHEN 'EXIT'.
PERFORM exit_program.
"$TMP
WHEN 'SAVE'.
PERFORM save_data.
WHEN OTHERS.
* do nothing
ENDCASE.
ENDMODULE. "pai INPUT
* FORM EXIT_PROGRAM *
FORM exit_program.
LEAVE PROGRAM.
ENDFORM. "exit_program
*& Form SAVE_DATA
* text
FORM save_data. "$TMP
* define local data
data: ls_fcat type lvc_s_fcat,
lt_fcat type lvc_t_fcat.
lt_fcat = gt_fieldcat.
ls_fcat-edit = ' '.
modify lt_fcat from ls_fcat
TRANSPORTING edit
where ( edit = 'X' ). " display ALV should be not editable
" Simulate saving of data
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'Display modified list data'
* I_GRID_SETTINGS =
* IS_LAYOUT_LVC =
IT_FIELDCAT_LVC = lt_fcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS_LVC =
* IT_SORT_LVC =
* IT_FILTER_LVC =
* IT_HYPERLINK =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT_LVC =
* IS_REPREP_ID_LVC =
I_SCREEN_START_COLUMN = 5
I_SCREEN_START_LINE = 5
I_SCREEN_END_COLUMN = 120
I_SCREEN_END_LINE = 20
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IT_EXCEPT_QINFO_LVC =
* IR_SALV_FULLSCREEN_ADAPTER =
TABLES
t_outtab = gt_outtab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "SAVE_DATA
*& Form BUILD_FIELDCAT
* text
* <--P_GT_FIELDCAT text
FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SBOOK'
CHANGING
ct_fieldcat = pt_fieldcat.
LOOP AT pt_fieldcat INTO ls_fcat.
* Exchange smoker field with invoice field - just to
* make the dependance between SMOKER and CLASS more transparent
* (Smoking is only allowed in the first class).
IF ls_fcat-fieldname EQ 'SMOKER'.
ls_fcat-col_pos = 11.
ls_fcat-outputlen = 10.
MODIFY pt_fieldcat FROM ls_fcat.
ELSEIF ls_fcat-fieldname EQ 'INVOICE'.
ls_fcat-col_pos = 7.
MODIFY pt_fieldcat FROM ls_fcat.
ELSEIF ls_fcat-fieldname EQ 'CLASS'.
*§3.Set your dropdown field editable and assign the fieldname of the
* corresponding additional field to DRDN_FIELD of the fieldcatalog.
ls_fcat-edit = 'X'.
ls_fcat-drdn_field = 'DROP_DOWN_HANDLE'.
ls_fcat-outputlen = 5.
* Field 'checktable' is set to avoid shortdumps that are caused
* by inconsistend data in check tables. You may comment this out
* when the test data of the flight model is consistent in your system.
ls_fcat-checktable = '!'. "do not check foreign keys
MODIFY pt_fieldcat FROM ls_fcat.
ENDIF.
ENDLOOP.
ENDFORM. "build_fieldcat
*& Form CREATE_AND_INIT_ALV
* text
* <--P_GT_OUTTAB text
* <--P_GT_FIELDCAT text
* <--P_GS_LAYOUT text
FORM create_and_init_alv CHANGING pt_outtab TYPE STANDARD TABLE
pt_fieldcat TYPE lvc_t_fcat.
DATA: lt_exclude TYPE ui_functions.
CREATE OBJECT g_custom_container
EXPORTING
container_name = g_container.
CREATE OBJECT g_grid
EXPORTING
i_parent = g_custom_container.
PERFORM build_fieldcat CHANGING pt_fieldcat.
* Optionally restrict generic functions to 'change only'.
* (The user shall not be able to add new lines).
PERFORM exclude_tb_functions CHANGING lt_exclude.
PERFORM set_drdn_table.
PERFORM build_data CHANGING pt_outtab.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
it_toolbar_excluding = lt_exclude
CHANGING
it_fieldcatalog = pt_fieldcat
it_outtab = pt_outtab[].
* Set editable cells to ready for input initially
CALL METHOD g_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
ENDFORM. "CREATE_AND_INIT_ALV
*& Form EXCLUDE_TB_FUNCTIONS
* text
* <--P_LT_EXCLUDE text
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
* Only allow to change data not to create new entries (exclude
* generic functions).
DATA ls_exclude TYPE ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
APPEND ls_exclude TO pt_exclude.
ENDFORM. " EXCLUDE_TB_FUNCTIONS
*& Form set_drdn_table
* text
* --> p1 text
* <-- p2 text
FORM set_drdn_table.
*§2.Define a dropdown table and pass it to ALV.
* One listbox is referenced by a handle, e.g., '1'.
* For each entry that shall appear in this listbox
* you have to append a line to the dropdown table
* with handle '1'.
* This handle can be assigned to several columns
* of the output table using the field catalog.
DATA: lt_dropdown TYPE lvc_t_drop,
ls_dropdown TYPE lvc_s_drop.
ls_dropdown-handle = '1'.
ls_dropdown-value = 'F'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = 'F'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = 'C'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = 'Y'.
APPEND ls_dropdown TO lt_dropdown.
CALL METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down = lt_dropdown.
ENDFORM. " set_drdn_table
*& Form build_data
* text
* --> p1 text
* <-- p2 text
FORM build_data CHANGING pt_outtab TYPE STANDARD TABLE.
DATA: lt_sbook TYPE TABLE OF sbook,
ls_sbook TYPE sbook,
l_index TYPE i,
ls_outtab LIKE LINE OF gt_outtab.
SELECT * FROM sbook INTO TABLE lt_sbook UP TO g_max ROWS."#EC CI_NOWHERE
IF sy-subrc NE 0.
PERFORM generate_entries CHANGING lt_sbook.
ENDIF.
*§4.Set the handle of your additional field of your output
* table according to the listbox that shall be displayed.
LOOP AT lt_sbook INTO ls_sbook.
l_index = sy-tabix.
MOVE-CORRESPONDING ls_sbook TO ls_outtab.
CLEAR ls_outtab-class.
* Alternate between smoker and non smoker to make
* it more obvious what this example is about
l_index = l_index MOD 2.
IF l_index EQ 1.
ls_outtab-smoker = 'X'.
ELSE.
ls_outtab-smoker = ' '.
ENDIF.
IF ls_outtab-smoker EQ 'X'.
ls_outtab-drop_down_handle = '1'.
ELSE.
ls_outtab-drop_down_handle = '2'.
ENDIF.
APPEND ls_outtab TO pt_outtab.
ENDLOOP.
ENDFORM. " build_data
*& Form generate_entries
* text
* <--P_LT_SLFIGHT text
FORM generate_entries CHANGING pt_sbook TYPE STANDARD TABLE.
DATA: ls_sbook TYPE sbook,
l_month(2) TYPE c,
l_day(2) TYPE c,
l_date(8) TYPE c,
l_prebookid TYPE i.
ls_sbook-carrid = 'LH'.
ls_sbook-connid = '0400'.
ls_sbook-forcurkey = 'DEM'.
ls_sbook-loccurkey = 'USD'.
ls_sbook-custtype = 'B'.
DO 110 TIMES.
l_prebookid = sy-index.
ls_sbook-forcuram = sy-index * 10.
ls_sbook-loccuram = ls_sbook-loccuram * 2.
ls_sbook-customid = sy-index.
ls_sbook-counter = 18.
ls_sbook-agencynum = 11.
l_month = sy-index / 10 + 1.
DO 2 TIMES.
l_day = 3 + l_month + sy-index * 2.
l_date+0(4) = '2000'.
l_date+4(2) = l_month.
l_date+6(2) = l_day.
ls_sbook-fldate = l_date.
SUBTRACT 3 FROM l_day.
ls_sbook-order_date+0(6) = l_date+0(6).
ls_sbook-order_date+6(2) = l_day.
ls_sbook-bookid = l_prebookid * 2 + sy-index.
IF sy-index EQ 1.
ls_sbook-smoker = 'X'.
ELSE.
ls_sbook-smoker = space.
ENDIF.
ls_sbook-luggweight = l_prebookid * 10.
IF ls_sbook-luggweight GE 1000.
ls_sbook-wunit = 'G'.
ls_sbook-class = 'C'.
ELSE.
ls_sbook-wunit = 'KG'.
ls_sbook-class = 'Y'.
ENDIF.
IF ls_sbook-bookid > 40 AND ls_sbook-wunit EQ 'KG'.
ls_sbook-invoice = 'X'.
ENDIF.
IF ls_sbook-bookid EQ 2.
ls_sbook-cancelled = 'X'.
ls_sbook-class = 'F'.
ENDIF.
APPEND ls_sbook TO pt_sbook.
ENDDO.
ENDDO.
ENDFORM. " generate_entries
Regards
Uwe -
Concatenation of Data from 4 infoobjects into a single cell in Bex Report
Hi,
I have loaded ODS with the description data. The source system for loading the ODS is the flat file. The ODS data should be a replica of the flat file.
In the flat file, there is a description field corresponding to a particular ID. This Description is greater than the standard 60 char length. So, I had to split the description while loading the flat file using single line routine in the Transfer Structure.
So, while loading different the data, I split the description field data from the flat file into 4 infoobjects and the flat file data was loaded into the ODS.
Now, from the reporting point of view, I need to display the entire description data from the 4 info-objects into a single cell in the Bex report.
Please suggest a solution for this.
<b>****Points will be awarded***</b>Hi Vineet,
Thanks for the response.
Could you please help me out with the VBA script(code) that needs to be written in the macro.
Thanks in Advance.
<i><b>****Points will be awarded****</b></i>
Regards,
Hitesh Shetty. -
Multiple values in a single cell in report !!
Hello,
I want to display multiple values in a single cell, each value separated by comma.
Ex: I have Employee and Department.
If a employee works for many departments, all the Department names should be displayed in the same cell in the report.
Please help !Thanks for your replies !
Is there any other way to achieve this ?
There is 1 InfoObject which has 2 fields Employee and Department.
Employee Department
001 A
001 B
001 C
In the report there should be 1 row for Employee 001 with all the Departments displayed in the same cell separated by commas.
Can this be done in the backend through a ABAP code? -
How to disable single cell in table control.
Hi my requirement is to disable single cell in the table control. Please let me know How to do this.
If possible please provide good module pool examples.
HarishHi,
I´m not quite sure if this is gonna work. You have to make a loop over the screen and then you can change some characteristics of it, which includes the Input option:
LOOP AT SCREEN.
IF screen-group1 = 'ABC'.
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
I´ve used this code for selection screens but could help you. Check in SE11 all options for SCREEN. -
I would like to know if there is a way to add multiple borders to a single cell or selection of cells in one click. At this time, if i want to add for example a top border and a bottom border to a single cell I have to do this in two steps: first select the top border, style, thickness, and color, and then next select the bottom border, style, thickness, and color. Is there a way to select the top and bottom border of a cell in one click? Clicking on the top border then holding down the command key while selecting the bottom border does not work, nor does holding down the option key, the control key, or the shift key work. Thanks for your help.
Thank you for the suggestion but this did not work for my Mac. When a cell is selected for which I want borders, the entire cell is lit up. Then when I go to the border tool and select style, thickness, and color, the entire lit up cell takes on the border, that is the Outside Edges of the cell now have a border. So selecting the style, thickness, and color first doesn't work.
If I select the top border first (or any border), the drop down goes away and I can't select multiple borders - I get to choose one at a time. After selecting one border, style, thickness, and color, said border is now on the spreadsheet. Then I go back to the border selection and pick another border and the the previously selected style, thickness, and color reverts to null, so I start over with the new border style, thickness, and color. Yes, it is tedious.
The Fix would allow the user to select multiple borders, say left and right, before the drop down goes away after selecting only one border
Does it have something to do with Allow or Disallow border selection?
I have Numbers '09 version 2.1 (436)
Maybe you are looking for
-
Due to a scam invading my computer recently, I cannot block these site in Parental Controls. This feature locks immediately and I must use Force Quit to close. Any ideas as to how to unlock Parental Controls? The two scams appear to be gone as I c
-
Query variable modification transport
I modified a query variable description in RRMX and a change request (let's call it CR1) gets created. But I wonder if I should go to RSA1 Transport Connection to add the variable to CR1? and how? I used to do this before quite a while ago and don
-
Logic Pro Froze in the middle of saving a project.
Logic Pro Froze in the middle of saving a project. It stayed that way for 30 minutes. When I forced quit, it did not save the project, and my last save was an hour previous (including project backup files). Is there a way to recover what I did, or ha
-
Copy express add on sap 8.8 -PLD coping problem
Dear Experts While coping the PLD from one database to another by using copy express ( sap 8.8 PL 00 ) only the empty layout (without any field) was creating. Pleas give the solution. Thanks
-
SAP Screen Personas - retain the conditional formatting
Hi, I am currently trying to find a way to retain the conditional formatting (done on the table in a flavor) after the data is exported to a excel spreadsheet. Also, would like to know if conditional formatting can be implemented on a report (e.g. ca